Command button to find specific info not working

aquitaine

New member
Local time
Today, 16:21
Joined
Jun 23, 2005
Messages
6
Hello,

I would be really grateful for some help. I have had this problem twice in two separate databases and cannot work out why it is happening. (it's for a good cause - amnesty international!)

I have a pretty basic database consisting of some tables - with one main one where all the entered info is kept. (au table)

I then have a form with several text and list boxes where the user can either enter data or select from a list. I added command buttons using the toolbox and wizard, asking it to match the information in the list/text box with records in the table, and return the matching ones. I have used this before with success.

My problem is, in this particular database, that some of them work, and some of them do not. I have one where you enter the reference number, then click the command button, which works perfectly. Another, for the year, also works. The two for region, and country (pays), do not return any records. (needless to say the records do exist)

In another database, I have something similar, and one search works perfectly but one returns an inaccurate number of records.

any ideas what is going wrong? I can explain the database further if necessary, but it is really quite a simple thing. It is attached zipped (but in french).

thank you
Eleanor
 

Attachments

For the schregioncmd2_Click() your criteria should read:

Code:
stLinkCriteria = "[region]=" & "'" & Me.schregion.Column(1) & "'"


For schpayscmd1_Click() your criteria should read:

Code:
stLinkCriteria = "[pays]=" & "'" & Me.schpays.Column(1) & "'"

Since your combo boxes are bound to the first column, which is the ID number for the country or region, you need to specify the second column when you pass the value to the form you are opening, otherwise you pass the bound column by default (remember that in VB, unless you chage the settings, the first column is always "0", not "1").

In this case had you used the ID number in the query behind the form you would have been okay, but since you used the value rather than the ID, which works fine in your case, you need to pass the value and not the ID.

Hope this helps!
 
Last edited:

Users who are viewing this thread

Back
Top Bottom