Keep first form on same record

cliff7376

Registered User.
Local time
Today, 03:14
Joined
Oct 10, 2001
Messages
107
I have a form that checked to see if a part number was entered into the DB. I Have made some code to check and if the part was not entered open up the part entry form for them to enter it in. The problem I am facing is that once they are done entering the new part in and close the form the first form kicks out of the current record it was on and goes back to record 1. Here is the code I am using. Can anyone tell me why this happens?

Thanks
Sean

Dim partanswer As String
If IsNull(DLookup("[PRT_PartNumber]", "PRT", "[PRT_PartNumber] = '" & Me!Cmboprtnum.Value & "'")) Then
partanswer = MsgBox("The Part Number " & Me.Cmboprtnum.Value & " Is not in the Item card. Would you like to add it now?", vbYesNo)
End If
If partanswer = vbYes Then
DoCmd.OpenForm "frmNewPart", acNormal, , , acFormAdd, acDialog
Else
Cancel = True
End If
 
Initial Observations:

What event is the code running on?

partanswer should not be a string as vbYes et al are enumerated constants (that is, they represent numeric values) and not text

You are using both early (Me.) and late binding (Me!) to do essentially the same thing. Stick with one, preferable early binding.

.Value is unnecessary as it's the default property for most controls.
 
Those are good suggestions. I will fix those. The event is running in the before update of the control. The part number is a string becouse our part numbers use alpha numeric charachters. Do you know why it is going to record one once the new form closes?
 
nevermind. I had a requery statement in my click event for some reason. It's all good now.

Thanks
 

Users who are viewing this thread

Back
Top Bottom