tanolalano
Technical User
Hi everyone,
I search in the forum but I get no answer to my needs.
In my form I have 2 button.
Button1 (btn1) one is enabled when a record in a table (tbl1) does not exist
and Button2 (btn2) is enable when a record in another table (tbl2) doas not exist.
The question is...
How can i disable btn1 if a record exist in tbl2? and viceversa??
I try this code but not works well, i.e. if record exist in tbl1 it disable btn1 but not btn2!
Any suggestions of how I should approach this will be helpful.
Thanks,
Tano
I search in the forum but I get no answer to my needs.
In my form I have 2 button.
Button1 (btn1) one is enabled when a record in a table (tbl1) does not exist
and Button2 (btn2) is enable when a record in another table (tbl2) doas not exist.
The question is...
How can i disable btn1 if a record exist in tbl2? and viceversa??
I try this code but not works well, i.e. if record exist in tbl1 it disable btn1 but not btn2!
Code:
If Me.[id_ord] <> 0 Or Not IsNull(Me.id_ord) Then
Set db = CurrentDb()
Set rst = db.OpenRecordset("tbl1", dbOpenDynaset)
rst.FindFirst "[id_ord] = " & Str(Nz(Me![id_ord], 0))
If rst.NoMatch Then
btn1.Enabled = True
Else
btn1.Enabled = False
btn2.Enabled = False
rst.Close
db.Close
Set rst = Nothing
Set db = Nothing
End If
End If
If Me.[id_ord] <> 0 Or Not IsNull(Me.id_ord) Then
Set db = CurrentDb()
Set rst1 = db.OpenRecordset("tbl2", dbOpenDynaset) '->era
rst1.FindFirst "[id_ord] = " & Str(Nz(Me![id_ordine], 0))
If rst1.NoMatch Then
btn2.Enabled = True
Else
btn2.Enabled = False
btn1.Enabled = False
rst1.Close
db.Close
Set rst1 = Nothing
Set db = Nothing
End If
End If
Any suggestions of how I should approach this will be helpful.
Thanks,
Tano