Open form to check values?

jeo

Registered User.
Local time
Today, 23:44
Joined
Dec 26, 2002
Messages
299
I’m checking to see if a value in one form for a combobox is the same is a value in another forms combobox.
What I did is I used the Forms!frmForm2!combo1 = Forms!frmForm1!combo1
When I use this in my Form1, it’s saying that it can’t find my Form2. When I open my Form2, then it works fine.
Should I be checking against a table or a query value instead of checking the form value?
I really don’t want to open the other form.
Thanks.
 
Yes, check the table/query entries via DAO/ADO or query. Forms have to be open, visible or hidden, before controls can be referenced.
 
Could you tell me how to do that?
 
private sub Button_Click()
dim db as dao.database
dim rs as dao.recordset
set db=currentdb
set rs=db.openrecordset("tableTwo",dbopensnapshot)
'if Forms!frmForm2!combo1 is an interger
rs.findfirst "IndexForTableOneandTableTwo=" & Forms!frmForm2!combo1
'if Forms!frmForm2!combo1 is a sring
rs.findfirst "IndexForTableOneandTableTwo=" & chr(34) & Forms!frmForm2!combo1 & chr(34)
if rs.nomatch then
msgbox "Record not found"
goto Exit_Exit
end if
if Forms!frmForm2!combo1=rs!FieldName then
'fields match, do whatever
else
'fields do not match, do whatever
end if
Exit_Exit:
rs.close
db.close
set rs=nothing
set db=nothing
end sub
 
Thank you for the post...I will try and decipher through this.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom