View Full Version : Help with access Database please


neeeeeeeeeek
20-04-2005, 10:47
Some Monkey I work with is having problems with an access database. Obviously someone with my vast knowledge could help him but I thought I would give you peasants a chance.
:D


Dim Msg As String
Dim Title As String
Dim Defvalue As String
Dim Answer As String

Msg = "FILTER BY"
Title = "FILTER"
Defvalue = "***"
Answer = InputBox(Msg, Title, Defvalue)
If Answer <> "" Then
DoCmd.OpenForm "TESTFORM", , , "[FIELD1]='" & Answer & "' "
Else
DoCmd.OpenForm "TESTFORM"
End If
End Sub


The above string filters data into a form - I want to add a second string that does not require a user input for example

The form will ask for a FILTER - i will input 001, i then want it to also filter FIELD 2 = 0


Come on Joe, I sense you are the man for this.


Cheers people.

AaronD
20-04-2005, 12:31
Hi,
The microsoft site does say that you can use a valid SQL WHERE clause so maybe this will work.

"[FIELD1]='" & Answer & "' AND [FIELD2]=0"

Otherwise you could probably use a query and pass in Answer as a parameter and have the query filter FIELD 2

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbaac11/html/acactOpenForm_HV01122149.asp

Using VB in Access isn't my thing though so I could be way off.

Aaron