Checking table entries vs ComboBox value

  • Thread starter Thread starter DubboPete
  • Start date Start date
D

DubboPete

Hello all,

I'm tired, it's the last thing I have to do, and I can't think!

I want to check a table when a combo box value is selected, and if the
record already exists in that table, I want a message box to pop up
and delay further action (which I can code quite happily!)

basically, it's:

If me.combo2 = existing related value in tblrecords then
if msgbox "question....", vbyesno then

et cetera, et cetera

Anyone willing to help out a poor overworked and underpaid yada yada
yada?

DubboPete
 
Assuming the value in Combo2 is text

If DLookUp("[FieldName]","[tblRecords]","[FieldName] = '" & Combo2 & "'") Then
 
Assuming the value in Combo2 is text

If DLookUp("[FieldName]","[tblRecords]","[FieldName] = '" & Combo2 & "'") Then



DubboPete said:
Hello all,
I'm tired, it's the last thing I have to do, and I can't think!
I want to check a table when a combo box value is selected, and if the
record already exists in that table, I want a message box to pop up
and delay further action (which I can code quite happily!)
basically, it's:
If me.combo2 = existing related value in tblrecords then
   if msgbox "question....", vbyesno then
et cetera, et cetera
Anyone willing to help out a poor overworked and underpaid yada yada
yada?
DubboPete- Hide quoted text -

- Show quoted text -

ah, but it's a number.....
 
Hello all,

I'm tired, it's the last thing I have to do, and I can't think!

I want to check a table when a combo box value is selected, and if the
record already exists in that table, I want a message box to pop up
and delay further action (which I can code quite happily!)

basically, it's:

If me.combo2 = existing related value in tblrecords then
   if msgbox "question....", vbyesno then

et cetera, et cetera

Anyone willing to help out a poor overworked and underpaid yada yada
yada?

DubboPete

Thanks Dennis,

You pointed me in the right direction, and my MsgBox popped up "Yada
yada yada" !

Here's the code I used:

If DLookup("[UID]", "Transfers", "[UID] = [FORMS]![FrmLastDose1]!
[Combo2]") Then
MsgBox "Yada yada yada"
Else
'do nothing
End If

many thanks

Pete
 
For a number use

If DLookUp("[FieldName]","[tblRecords]","[FieldName] = " & Combo2) Then

DubboPete said:
Assuming the value in Combo2 is text

If DLookUp("[FieldName]","[tblRecords]","[FieldName] = '" & Combo2 & "'") Then



DubboPete said:
Hello all,
I'm tired, it's the last thing I have to do, and I can't think!
I want to check a table when a combo box value is selected, and if the
record already exists in that table, I want a message box to pop up
and delay further action (which I can code quite happily!)
basically, it's:
If me.combo2 = existing related value in tblrecords then
if msgbox "question....", vbyesno then
et cetera, et cetera
Anyone willing to help out a poor overworked and underpaid yada yada
yada?
DubboPete- Hide quoted text -

- Show quoted text -

ah, but it's a number.....
 
Back
Top