VBA Tracking issues User Login

Neilster

Registered User.
Local time
Yesterday, 22:18
Joined
Jan 19, 2014
Messages
218
Hi Guys

I have this code storing login times on a table which is fine when logging in and out, however on the login screen when the user enters their username it stores it as a number on the table and not their name??

CurrentDb.Execute "INSERT INTO tblLogInTime (EmpName,[Logintime]) VALUES ('" & cboEmployee & "', Now())", dbFailOnError

Can anyone help please :D:D

:banghead::banghead:
 
it will obviously store the bound column of your combobox....
Try
CboEmpleyee.columns(1)

Not sure if it column or columns.....
 
Hi

Thanks for getting back, I have tried both CboEmpleyee.columns(1) & CboEmpleyee.column(1) and I'm coming up with a run time error '424'
 
Your combobox does have 2 columns, right?
 
SELECT [TblEmployee].[EmpID], [TblEmployee].[EmpName] FROM [TblEmployee] ORDER BY [EmpName];
 
Yes bound column is 1, but you have 2 columns.
The bound column is stored hence cboEmployee returning the bound column, which probably is hidden too.

The second column is the name, which is displayed and you want to have that stored in your table.
Me.CboEmpleyee.column(1)
Will return that value assuming cboEmployee is the name of the control of the form that you are running this code from.
 
It works a beauty, however when I log back in and press login button I get a compile error - Method or data member not found

so I rewrite Me.CboEmpleyee.column(1) and then lets me into the DB and when I look in the table it's got the name which is ace but I always get a compile error - Method or data member not found when login?
 
Don't worry I've sorted it out, thanks for all your help.

:) :) :) :)
 
So what was the cause of the error, did you mistype something?
 
Just simply Me.CboEmployee seemed to not work as Me.cboEmployee did, funny old world Access.
 

Users who are viewing this thread

Back
Top Bottom