Jumat, 15 April 2016

[MS_AccessPros] Insert Statement

 

Hello all,


I have an insert statement in vba that allows me to log when a couple of buttons are clicked and some other information related to it. I was thinking of adding one more function to the insert statement. I want to add the users logged name from a text box I have on a form. the name of the text box is txtUser and the On form load is the following to populate the txtUser control


Private Sub Form_Load()
Me.txtUser = Environ("UserName")
End Sub


Currently the code is


CurrentDb.Execute "INSERT INTO tblTransferDate (TransferDate, ButtonClicked, FinalObject) " & _
   "Values(Date() + Time(), 'cmdAddEmployee', 'Add New Record')", dbFailOnError




But I would like to add the value from the txtUser control but I cannot find a way to add the control. I get an error when I try the below code. Run-time error 3061 too few parameters. Expected 1


CurrentDb.Execute "INSERT INTO tblTransferDate (TransferDate, ButtonClicked, FinalObject, UserLoggedIn) " & _
   "Values(Date() + Time(), 'cmdAddEmployee', 'Add New Record', Me.txtUser.value)", dbFailOnError



How do I add that text control to the insert statement.


Thank You Very Much


Jim Wagner

__._,_.___

Posted by: luvmymelody@yahoo.com
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (18)

.

__,_._,___

Tidak ada komentar:

Posting Komentar