Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Syntax for Form Filter for 2 variables

Status
Not open for further replies.

MooYai

Technical User
May 16, 2003
12
DE
Hi,

I have a problem to open a form from another form by setting the Filter for the form to be opened. I want to open that form lets call it formB which depends on two variables 'songId' and 'songOffset'. I am using the following code in the form Load event of formB for one variable:

(intSongOffset = "0" value defined in formA,this
is only for testing here)

Me.Filter = "SongOffset = " & intSongOffset

where intSongOffset will be calculated in another form: formA.

This works fine. But what syntax do I have to use for 2 variables connected by an "AND" - condition. I tried several things but al failed with various error msg's.

Can somebody help


Thanks

Thomas
 
Hi!

I think the syntax should be something like:

[tt]"SongOffset = " & intSongOffset & " AND songID = " & intVariableName[/tt]

Both fields being numeric, ensure that the variables contains values, typing...

To check it, you might try to set the filter manually, using the same values as in the code, and then use Debug.Print Me.Filter in some routine to study how Access sets the filter (CTRL+G to open the immidiate pane).

Should this path not lead to solution, you might also consider using the where condition when opening the form (since you say at least one of the values are calculated in the "formA", this could perhaps be used):

[tt]docmd.openform "FormB",,,"SongOffset = " & intSongOffset & " AND songID = " & intVariableName[/tt]

- all on one line

If none of these works, consider posting your code and error messages (please also names and datatypes of the fields).

HTH Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top