searching for records

peterbowles

Registered User.
Local time
Today, 20:45
Joined
Oct 11, 2002
Messages
163
I am using this code in a macros where condition
to open a form

Open Peopleform WHERE

Forms![Students]![StudentNumber] = [Student]![StudentNumber]

Or

Forms![Students]![ProgramNumber] = [Program]![ProgramNumber]

Studentnumber is txtbox on the search form

ProgramNumber is a txt box on the search form

If both txtboxes = a record in the Peopleform then the form is opened at that record

The problem is that the search form looks at both txtboxes and find recors that match both individual txtboxs

How do I say this

If both search criteria are used open the for WHERE conditions = a record in the form
or If just one search criteria is used open the form WHERE that condition = a record in a table

Can anyone please help me
Thankyou
 
I am sorry but I don't use macros so all I can give you is code... One of the manybenefits of moving from macros to code is much more flexibility...

If Not IsNull(Me![StudentNumber]) And Not IsNull(Me![ProgramNumber]) Then
DoCmd.OpenForm "PeopleForm", , , "[StudentNumber] = " & Me![StudentNumber] & " And [ProgramNumber] = & Me![ProgramNumber]
ElseIf Not IsNull(Me![StudentNumber]) And IsNull(Me![ProgramNumber]) Then
DoCmd.OpenForm "PeopleForm", , , "[StudentNumber] = " & Me![StudentNumber]
ElseIf IsNull(Me![StudentNumber]) And Not IsNull(Me![ProgramNumber]) Then
DoCmd.OpenForm "PeopleForm", , , "[ProgramNumber] = " & Me![ProgramNumber]
Else
MsgBox "You must enter data into Program Number or Student Number"
End if

I would actually create a query to do this, but that is another story for another time...

hth,
Jack
 

Users who are viewing this thread

Back
Top Bottom