| | |
|
|
|
Adding data to table |
| message from Techsupport on 2 Jun 2004 |
Good morning, everybody...I have a table (tblLogin) and two forms
(frmAddUser and frmUserLogInfo).
The frmUserLogInfo feeds from the tblLogin. Whenever a new user needs to be
added, I need to go to the frmAddUser and add all the information to the
tblLogin. frmAddUser is also bound to tblLogin (maybe that's the problem?).
This is the code I have:
Private Sub cmdAddUser_Click()
If IsNull(Username) Or IsNull(UserTitle) Or IsNull(Phone) Or
IsNull(Extension) Or _
IsNull(EMail) Then
MsgBox "All the fields are required. Please check your data.",
vbExclamation, _
"Missing Data"
DoCmd.CancelEvent
Exit Sub
Else
'insert the new record in the tblLogin table
Dim dbsA As Database, dbsB As Database
Set dbsA = CurrentDb
Set dbsB = CurrentDb
CurrentDb.Execute "INSERT INTO tblLogin SELECT * FROM "
'WHERE Username = " & Me.Username, dbFailOnError"
If Err.Number <> 0 Then
DoCmd.Beep
MsgBox Err.Number & vbCrLf & Err.Description
End If
Set dbsA = Nothing
Set dbsB = Nothing
MsgBox "The information has been added to the database.", vbInformation,
"User Added"
DoCmd.Close acForm, "frmAddUser"
DoCmd.OpenForm "frmUserLogInfo"
End If
End Sub
|
| John Vinson replied to Techsupport on 02 Jun 2004 |
Two questions:
- What problem are you having? You don't say.
- If you have a bound form, it will add the data to the table all by
itself; you don't need or want to run an Append query. Do you have
some reason to do it this way?
And an observation:
If you have a record open for editing on a Form, then no other form
nor any other query will be able to update that record, since it's
locked by the form. You'll get an error to the effect "the record is
locked by another user".
John W. Vinson[MVP]
Come for live chats every Tuesday and Thursday
http://go.compuserve.com/msdevapps?loc=us&access=public
|
| Techsupport replied to John Vinson on 2 Jun 2004 |
The bound for is frmAddUser.
I am trying to add users' information in the frmAddUser and have this
information copied to the tblLogin.
Antonio
"John Vinson" <jvinson@STOP_SPAM.WysardOfInfo.com> wrote in message
news:0a0sb05tddp3qn7f6rgj9ph28c4sm549f9@4ax.com...
|
|
Archived message: Adding data to table (MS Access)