Hopefully, this will make sense.
I am trying to open a form to a specific record if it exists, or add a record if it does not. But the check needs to be based on two criteria (the QuoteID and where "HandBraze" is True).
Whenever I use the following code, it opens to a new record each time.
I'm sure it is probably something quite simple, and I suspect it is to do with my Dlookup trying to find the "True" value, but I can't figure out how to do it.
Any help would be much appreciated.
Many thanks in advance,
Dave
I am trying to open a form to a specific record if it exists, or add a record if it does not. But the check needs to be based on two criteria (the QuoteID and where "HandBraze" is True).
Whenever I use the following code, it opens to a new record each time.
Code:
Private Sub HandBraze_AfterUpdate()
If HandBraze = True Then
Dim Exists As Boolean
If IsNull(Me.OrderQty) Then
MsgBox "Please enter a Diameter, Cut Length and Order Qty"
Me.Diameter.SetFocus
Me.HandBraze = False
Else
If DLookup("quoteid", "tblweldquotes", "quoteid = forms!frmpipequotation!quoteid") > 0 And DLookup("handbraze", "tblweldquotes", "quoteid = forms!frmpipequotation!quoteid") = True Then
Exists = True
Else
Exists = False
End If
If Exists = True Then
DoCmd.OpenForm "frmweldquote", , , "quoteid = " & QuoteID & "And [handbraze] =" & HandBraze, acFormEdit, acDialog
Else
DoCmd.OpenForm "frmweldquote", , , , acFormAdd, acDialog
End If
End If
ElseIf HandBraze = False Then
HandBrazeCost = ""
End If
End Sub
I'm sure it is probably something quite simple, and I suspect it is to do with my Dlookup trying to find the "True" value, but I can't figure out how to do it.
Any help would be much appreciated.
Many thanks in advance,
Dave