"Problem with new form??"

G

Guest

This is my first attempt at creating a form so any help will be greatly
appreciated.

I have the basic form and most of the codes ok for this form but would like
the code to test each entry and alert the op to input the correct value
before entering any of the data. All blanks or choices on this form should
be checked. The code below does check the first blank and alert the op like
I want, but if the second etc. entries are blank, the form posts to the data
sheet what has been entered and opens a new form. How can I get the form to
retain all the data that has been entered (but not transferit to the main
data sheet) and SetFocus on the empty cell?

If Trim(Me.txtFirstName.Value) = "" Then
Me.txtFirstName.SetFocus
MsgBox "Please Enter First Name!"
ElseIf Trim(Me.txtLastName.Value) = "" Then
Me.txtLastName.SetFocus
MsgBox "Please Enter Last Name!"
ElseIf Trim(Me.txtAddress.Value) = "" Then
Me.txtAddress.SetFocus
MsgBox "Please Enter Street Address!"

End If

ws.Cells(iRow, 1).Value = Me.txtFirstName.Value
ws.Cells(iRow, 2).Value = Me.txtLastName.Value
ws.Cells(iRow, 3).Value = Me.txtAddress.Value
ws.Cells(iRow, 4).Value = Me.txtCity.Value
ws.Cells(iRow, 5).Value = Me.txtState.Value

I can post the entire code if that's necessary. Hope I described what I'm
trying to do adequately.

TIA,

Don
 
T

Tom Ogilvy

check all the conditions and or otherwise record the offenders. then notify
the user.

Hard to tell about the update. If you are writing the values with code,
then don't write them.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top