TempVar in Form Issues... NO VBA (1 Viewer)

scorpio125

New member
Local time
Today, 06:32
Joined
Apr 17, 2014
Messages
8
Sorry if this is amateurish question,

I have an employee login form basic stuff Crew, Employee ID, location etc. This form creates these as TempVars.

This all works fine. Then I got to another form order entry and populate these fields into the form, this form is supposed to update the orders table.

Thing is my table is set up to use the keys for Employee ID, Crew, Location etc... The form however I need it to display the actual names, so the problem is when i go to update the table, it bombs out because the name is being passe to the table and not the key.

Example

Login Form:

Bob Smith -(Key is) 2

Carried over to Order Form via TempVar

Order Form:
Bob Smith is displayed bc key is meaningless to the end user.

Updating order table however needs Bob Smiths Key of 2 not his name.

Hope that makes sense.

In summary how to carry key along with the TempVar but not display it and then use it?

NO VBA just MS ACCESS options.

Thanks all.
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 14:32
Joined
Jul 9, 2003
Messages
16,280
From Access Help....
TempVar Object
Represents a variable that be used in Visual Basic for Applications (VBA) code or from a macro.
Version Information
Version Added: Access 2007

Remarks
A TempVar objects provide a convenient way to exchange data between VBA procedures and macros.

Although a TempVar object can be used to store information for use in VBA procedures, it does not have the same funcitonality as a VBA variable.
##By default, a TempVar object remains in memory until Access is closed. You can use the Remove method or the RemoveTempVar macro action to remove a TempVar object.
##In VBA, a TempVar object is accessible only to the members of the Access Application object, referenced databases, or add-ins.
##A TempVar object can store only text or numeric data. TempVar objects cannot store objects.

To refer to a TempVar object in a collection by its ordinal number or by its Name property setting, use the following syntax form:
TempVar![name]
 
Last edited:

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 14:32
Joined
Jul 9, 2003
Messages
16,280
I'm not a macro person, VBA is my game... I did manage to get a macro to create a Tempvar and and hold a value.

I created a message box macro , but couldn't figure out how to extract the tempvar value in to the message box String Message.

However I did extract the tempvar value with a message box in VBA...
 

vbaInet

AWF VIP
Local time
Today, 14:32
Joined
Jan 22, 2010
Messages
26,374
... it bombs out because the name is being passe to the table and not the key.

Bob Smith -(Key is) 2
Like Unlcle Gizmo I don't use macros but why don't you pass the record ID? And why isn't the form bound?

I created a message box macro , but couldn't figure out how to extract the tempvar value in to the message box String Message.
Just fyi, you can call it one of these ways:
Code:
TempVars![COLOR="Blue"]VariableName[/COLOR]
TempVars("[COLOR="blue"]VariableName[/COLOR]")
TempVars.Item("[COLOR="blue"]VariableName[/COLOR]")
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 14:32
Joined
Jul 9, 2003
Messages
16,280
I found the tempvar with VBA but I couldn't get a macro message box to append the tempvar to the text string in the message box? How would you do that or is it not possible? In other words how do you debug macros?
 

scorpio125

New member
Local time
Today, 06:32
Joined
Apr 17, 2014
Messages
8
Like Unlcle Gizmo I don't use macros but why don't you pass the record ID? And why isn't the form bound?

Can you give me more detail on this question? I am not familiar with Record ID and I am not sure I understand your question about the bound form?

Thanks!
 

vbaInet

AWF VIP
Local time
Today, 14:32
Joined
Jan 22, 2010
Messages
26,374
I see that you're creating a new record with the information from the login form so don't worry about that comment.

Does the login form stay open when you open the other form?
 

scorpio125

New member
Local time
Today, 06:32
Joined
Apr 17, 2014
Messages
8
No its the user id creates tempvariables

so when I get the entry screen I want it to show the employee name who logged in on the form BUT when updating the actual table I need the key to get passed to the table not the employee name.

Maybe this is another way to think.....

The employee record consists of 3 fields.... ID, First, Last

How do I set the TempVar to carry all 3 fields? Currently when I set it only one is available?

UGH.
 

vbaInet

AWF VIP
Local time
Today, 14:32
Joined
Jan 22, 2010
Messages
26,374
You'll need 3 TempVars. Why are you hooked on macros anyway?
 

scorpio125

New member
Local time
Today, 06:32
Joined
Apr 17, 2014
Messages
8
Because I am not a programmer this was dumped on me. Soon as I am done I won't be maintaining it either.
 

vbaInet

AWF VIP
Local time
Today, 14:32
Joined
Jan 22, 2010
Messages
26,374
It's much easier in VBA. Anyway, have you created the 3 tempvars?
 

Users who are viewing this thread

Top Bottom