closing form requesting values

G

Guest

I have a form that is based on a query. The where clase uses contains
references to two unbound combo boxes on the form. The user selects values
from the combo boxes and presses the command button on the form to requery.
When done the user press a command button to close the form.

SELECT Field1, Field2, etc..
FROM MyTable
WHERE ((Field1 = Forms![MyForms]![Comb1]) AND (Field1 =
Forms![MyForms]![Comb1]));

The Command Button code on click is simply
Me.Refresh
Me.Requery

The Close Command Button
DoCmd.Close acForm, "MyForm",acSaveNo

A problem occurs when a user closes the form, but only for some users. An
Access screen displayes requesting values for the Combo boxes. To date I
have:

I have search my entire system looking of other references to theses and
have found none.

Assigned values to the Combo Boexes prior to closing the form.

Changed the name of the combo boxes. The scren still displayes but with the
new names.

I would appreciate any comments. If I can't find the cause is there a way
to trap this so the users never see it?
 
C

Carl Rapson

Instead of including the two unbound controls in your query, you could
modify the form's RecordSource property in the command button Click event to
be the query SQL code, and include the two combo box values in the WHERE
clause there. Something like:

Me.RecordSource = "SELECT Field1, Field2, etc.." & _
" FROM MyTable" & _
" WHERE ((Field1 = '" & Me.Comb1 & "')" & _
" AND (Field2 = '" & Me.Comb2 & "'));"

Of course, this assumes the combo box values are strings; if they are
numbers, remove the single quotes:

" WHERE ((Field1 = " & Me.Comb1 & ")" & _
" AND (Field2 = " & Me.Comb2 & "));"

Carl Rapson
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top