JP D
asked on
Access Data Macro - Looking up a record using a value in a variable
Hello experts,
I have a named data macro (in Access 2013), which when called, I want it to find a specific record (within the table for which it is attached to) based upon a record key, which is saved in a tempvar. The tempvar is set in the macro which calls the data macro. However, I cannot seem to figure out how to get it to use the tempvar in the where condition.
Here is a better picture:
TVarSWSerKey = 71 (this tempvar is set in the calling macro, before the datamacro is called)
[sw_serials].[ser_key] = (this is a numerical field in the sw_serials table, and is the primary key)
Datamacro: sw_serials.uninstall (datamacro "uninstall", on the "sw_serials" table)
Look Up A Record In sw_serials
Where Condition = [sw_serials].[ser_key] = FormatNumber([TempVars]![T VarSWSerKe y])
The above where condition, does not seem to grab any record. If I replace "FormatNumber......" with the number 71, then the where condition successfully grabs the record with ser_key of 71. I've without the FormatNumber function, and with various different quotation formats, but can't seem to get it to work.
Any help?
I have a named data macro (in Access 2013), which when called, I want it to find a specific record (within the table for which it is attached to) based upon a record key, which is saved in a tempvar. The tempvar is set in the macro which calls the data macro. However, I cannot seem to figure out how to get it to use the tempvar in the where condition.
Here is a better picture:
TVarSWSerKey = 71 (this tempvar is set in the calling macro, before the datamacro is called)
[sw_serials].[ser_key] = (this is a numerical field in the sw_serials table, and is the primary key)
Datamacro: sw_serials.uninstall (datamacro "uninstall", on the "sw_serials" table)
Look Up A Record In sw_serials
Where Condition = [sw_serials].[ser_key] = FormatNumber([TempVars]![T
The above where condition, does not seem to grab any record. If I replace "FormatNumber......" with the number 71, then the where condition successfully grabs the record with ser_key of 71. I've without the FormatNumber function, and with various different quotation formats, but can't seem to get it to work.
Any help?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Please see my last posting on this question.
Discovered the solution myself, but the discovery was because of further tests which Scott McDaniel made me think of running.
Discovered the solution myself, but the discovery was because of further tests which Scott McDaniel made me think of running.
ASKER
I have been able to confirm that my variable is being set with the correct data, by temporarily placing a text box, and populating it with the TempVar, from within the same macro in which the TempVar is initially defined, and the datamacro is called.
When I run that macro, the text box shows the contents of the TempVar, which is correct.
However, I have not done anything similar, to confirm that the datamacro is in fact able to use the same TempVar.
I will have to test that, and will get back with the results.