Trouble setting Temp Var

ct2013

Registered User.
Local time
Today, 15:28
Joined
Jun 6, 2013
Messages
87
Hi there,

I have a table [Employees] which has the following Fields

- TxtEmpID

- StrEmpName

- StrEmpPassword


Which I use for my login table with the following script:

If Me.txtPassword.Value = DLookup("strEmpPassword", "tblEmployees", "[TxtEmpID]=" & Me.cboEmployee.Value) Then

TxtMyEmpID = Me.cboEmployee.Value

On my form the drop down to select the employee is “SELECT tblEmployees.[TxtEmpID], [tblEmployees].[strEmpName] FROM tblEmployees; “ (Seemingly all this is based on the TxtEmpID)

When I create a Temprorary Variable [SetTempVar – screen.activecontrol with the name “SetUserID”] and then want to place the variable in a form or whatever else, I can only see the TxtEmpID. I would like to set the TempVar as the field StrEmpName.

How is this possible??

Please reply ASAP
Many thanks
 
The StrEmpName is the 2nd column of your ComboBox.
 
To expand on RuralGuy's explanation, the RowSource of a combo is a zero based array. The bound element is what you get when you simply refer to the .value property. If you want to access other fields, you must use the .Column property.

Me.cboEmployee.Column(1) is the SECOND element (remember this is a zero-based array so the first element is .Column(0)) which based on your query will be strEmpName.
 
thanks,

it is the second column on my drop down.

how would i place it into this script?

TempVars.Add ???, "??"
 
TempVars.Add Me.Password.Column(1), “SetUserID
 
Many thanks for your reply.

Unfortunately I cant get that code to work.

attached is my sample DB. could you possibly let me know where I am going wrong.

Thanks a mill.
 

Attachments

I don't use macros. If you have a macro problem, try the macro forum.
 
Sorry unsure what you mean, Is it not code?I don't think I worked on macros on my logging in for?
 
Macros in Access are very different from Macros in Excel and Word where they are actually VBA. Macros in Access are definitely NOT VBA.

Your database has embedded macros. Probably because you let the wizards build the events for you.
 
Thanks for your response,

Is it a big job for you to change this as I am happy for you to change whatever necessary to get this working.

Thanks for all your help
 
There is an option to convert all macros to VBA. You could use that if you wanted to get rid of the macros.
 
Hi there,

I have done that now, would you mind to try and look at it again.

Thanks a mil:banghead:
 

Attachments

Users who are viewing this thread

Back
Top Bottom