Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Autonumber problem

Status
Not open for further replies.

jcpelejo

Programmer
Jul 29, 2001
70
US
Hello. I am having a problem with the AutoNumber feature. I have a login form that enters into a main form. It goes to a new record but the AutoNumber does not show the new number. It stays at (AutoNumber). I tried entering data into the fields associated with the AutoNumber but it does not create the new number. The code used is as follows:

Form 1 - "LOGIN FORM"
Private Sub cmdLogin_Click()

Dim rst As DAO.Recordset
Dim rstUser As DAO.Recordset
Dim rstLogin As DAO.Recordset
Dim strSQL As String

strSQL = "SELECT * FROM [User ID] WHERE UserID = '" & txtUserID & "'"

Set rst = CurrentDb.OpenRecordset("User ID", dbOpenDynaset)
Set rstUser = CurrentDb.OpenRecordset(strSQL, dbOpenSnapshot)
Set rstLogin = CurrentDb.OpenRecordset("User Login", dbOpenDynaset)

rst.FindFirst "UserID = '" & txtUserID & "'"

If rstUser.EOF = True And rstUser.BOF = True Then
Call MsgBox("The User ID you entered is invalid")
Call txtUserID.SetFocus
Else
If rstUser!Password = txtPassword And rst.NoMatch = False Then
rstLogin.AddNew
rstLogin!UserID = txtUserID
rstLogin!LogDate = Date
rstLogin!LogTime = Time()
rstLogin.Update
DoCmd.OpenForm "Manual Claims System - MR Canada"
Call MsgBox("Welcome " & rst!UserFirstName & " " & rst!UserLastName & " to the Manual Claims System - MR Canada")
DoCmd.GoToRecord acActiveDataObject, txtClaimNumber1, acNewRec
DoCmd.Close acForm, "Login Form"
Else
Call MsgBox("The password you entered does not match the User ID")
Call txtPassword.SetFocus
End If
End If

End Sub
-----------------------------------------------------------
Form 2 - "MANUAL CLAIMS SYSTEM - MR CANADA"
Textbox - [ClaimNumber] set to (AutoNumber)
Textbox - [UserID] default set to "[Forms]![Login Form]![txtUserID]"

Please advise. Life is too short to waste...
Julius Pelejo
jcpelejo@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top