Dealing with an error

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have two forms. The first form is to set up new customers and the second form is to edit existing customers. There is an unbound text box on the first form for the user to enter an existing customer number and then a command button that opens up the second form with the customer number's info from the unbound text box on the first form. If the user enters a number that isn't in the data base, I don't want the second form to open up - just stay with the first form for the user to re-enter the correct number. Below is the code I tried. I can't get the first form to stay open. Can you help me? Thanks..

Private Sub Form_Open(Cancel As Integer

If IsNull(Me.CUSTOMER) The
MsgBox "The customer number does not exist", vbOKOnly, "INPUT ERROR
DoCmd.OpenForm "frmCUSTOMER_ADD", acNormal, , , acFormPropertySetting
DoCmd.Close acForm, "frmCUSTOMER_ADD_EDIT", acSaveN
Els
Me.CUSTOMER.SetFocu
End I

End Sub
 
The problem is that the box is not null, it has a number
in it. You need to look in the table for that number.



If IsNull(Dlookup
("CustomerID","tblCustomers","CustomerID=" & Me.Customer))
Then

....DO error stuff here

End If



Chris Nebinger

-----Original Message-----
I have two forms. The first form is to set up new
customers and the second form is to edit existing
customers. There is an unbound text box on the first form
for the user to enter an existing customer number and then
a command button that opens up the second form with the
customer number's info from the unbound text box on the
first form. If the user enters a number that isn't in the
data base, I don't want the second form to open up - just
stay with the first form for the user to re-enter the
correct number. Below is the code I tried. I can't get
the first form to stay open. Can you help me? Thanks...
 
Back
Top