S
s4
Hi, I have a DB where you can add a list of items. I'm trying to however make
it so that if you try adding an item more than once it will stop you. I've
done this before where it finds the item and lets you change the quantity. I
can't get this one to work though, can someone please check my code??
It's a bit messy because I've just been seeing if I could change bits etc to
get it working.
FND = DLookup("plu_code", "tbl_supps", "[sup_item] like '*" & Me.Text8 & "*'")
FOUND = DLookup("barcode", "tbl_barcs", "[plu_code] = '" & FND & "'")
Select Case MsgBox("The closest match for supplier code " & Me.Text8 & " is:
" & Chr(13) & FOUND & Chr(13) & "Would you like to use this item?", vbYesNo,
"Found Items")
Case Is = vbYes
If (DLookup("FIELD1", "SD_PLP", "[FIELD1] ='" & FOUND & "'")) <> Null Then
DoCmd.GoToControl "FIELD1"
DoCmd.FindRecord FOUND, acAnywhere, , acSearchAll, , acAll
DoCmd.GoToControl "FIELD7"
MsgBox "FOUND"
Exit Sub
Else
DoCmd.GoToRecord , , acNewRec
Me.Field1 = FOUND
DoCmd.GoToControl "FIELD7"
MsgBox (DLookup("FIELD1", "SD_PLP", "[FIELD1] ='" & FOUND & "'"))
End If
The messagebox always shows as if it is there but never acts so.
Thanks for any help!
it so that if you try adding an item more than once it will stop you. I've
done this before where it finds the item and lets you change the quantity. I
can't get this one to work though, can someone please check my code??
It's a bit messy because I've just been seeing if I could change bits etc to
get it working.
FND = DLookup("plu_code", "tbl_supps", "[sup_item] like '*" & Me.Text8 & "*'")
FOUND = DLookup("barcode", "tbl_barcs", "[plu_code] = '" & FND & "'")
Select Case MsgBox("The closest match for supplier code " & Me.Text8 & " is:
" & Chr(13) & FOUND & Chr(13) & "Would you like to use this item?", vbYesNo,
"Found Items")
Case Is = vbYes
If (DLookup("FIELD1", "SD_PLP", "[FIELD1] ='" & FOUND & "'")) <> Null Then
DoCmd.GoToControl "FIELD1"
DoCmd.FindRecord FOUND, acAnywhere, , acSearchAll, , acAll
DoCmd.GoToControl "FIELD7"
MsgBox "FOUND"
Exit Sub
Else
DoCmd.GoToRecord , , acNewRec
Me.Field1 = FOUND
DoCmd.GoToControl "FIELD7"
MsgBox (DLookup("FIELD1", "SD_PLP", "[FIELD1] ='" & FOUND & "'"))
End If
The messagebox always shows as if it is there but never acts so.
Thanks for any help!