Results 1 to 5 of 5

Thread: Question on code for a form in Access....Please help

Threaded View

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2005
    Posts
    53

    Exclamation Question on code for a form in Access....Please help

    Hello,
    Ok I have a table that starts with a number field. I aslo have the form using the same format as the table.. I have the user enter in the number in the first field. If the user leaves it blank and tries to add the record it will ask the user to enter in the number. I have the table in ascending order. I don't want the user to enter any other number other than the previous plus 1. For instance if the user inputs 1 for the number field, the next record can only start with 2. If the user enters in 44 for the first record, the next one can only be 45. Right now I have a button on the form that adds record to table as long as all field have been entered. If any are blank a message comes up asking user to enter input accordingly. For the number field if left blank message comes up..."please enter number".. User enters 1 in that field and fills the rest of form properly. The user clicks the add button. Record is entered into table. Now its time to add another record. The user has to enter in 2 in the number field for record to be added...I dont want the user to be able to enter in any other number other than the next number in sequence.

    This is what I have for code:

    Number.SetFocus
    If Number.Text = "" Then
    MsgBox "Please enter Number.", vbOKOnly, "Number"
    Exit Sub
    End If
    Number.SetFocus
    If Number.Text <> Number + 1 Then
    MsgBox "Please enter the next Number in sequence.", vbOKOnly, "Number"
    Exit Sub
    End If

    The second if statement is wrong...but the logic is what I want...Im not sure on how to code it..also not sure how to declare a variable so that the if statement will beable to recognize the number from previous record.

    Please Help
    Last edited by noycwild; May 31st, 2005 at 09:23 AM. Reason: Spelling error

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width