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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Opening a Form on Link Criteria 1

Status
Not open for further replies.

bostonfrog

Programmer
Jul 14, 2003
79
MX
I have a problem with a form which will open a second form and filter it on the criteria below. The behavior of the form that is being opened doesn't always filter, though, and I'm not sure why.
Code in command button:

Code:
Dim LinkCriteria As String
LinkCriteria = "[ID] & [Date]= " & "'" & Me![ID] & Me![Date] & "'"
DoCmd.OpenForm "FormName", acNormal, , LinkCriteria

When this button behaves correctly, it displays the form with the number of records filtered in the record navigation bar, e.g. 2 records (Filtered), based on the client's ID and purchase date, for example. But mostly it's not working, and goes to the first record in the recordset of the form that's being opened. Any ideas?
 
Have you tried using Trm function to get rid of any unwanted spaces??? If not give that a whirl.

If I take a peek in your Windows, to fix a problem, does that make me a "Peeping Tom"? Hmmmmmmmmmm
 
Why not seperate out your two fields:

LinkCriteria = "[ID]=" & me![ID] & " AND [Date]=#" & me![date] & "#"

I am assuming that ID is a numeric value otherwise you'll need to put single quotes around it like this:

"[ID]='" & me![ID] & "'"

You should always put the pound sign in front of dates in a SQL statement so that Access will evaluate the value correctly.

Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top