Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variable Type Issue?

Status
Not open for further replies.

scoobey

Technical User
Sep 18, 2001
32
GB
Hi again!
As in my previous thread, I am trying to create a 'template' form, which is automated from the forms record source.
Using the code below, I am able to obtain the primary key field name from the recordset for use on some select statements:

var_TableSrc = Form.RecordSource
var_PrimaryKey = CurrentDb.TableDefs(var_TableSrc).Indexes("PrimaryKey").Fields(0).Name
var_PrimaryKeyFrmName = var_PrimaryKey

The variable 'var_PrimaryKey' returns 'MachineName', which is correct as this is the primary key in the recordset. However, 'var_PrimaryKeyFrmName' also returns 'MachineName'. I need this to contain the current MachineName value, eg 'Desktop1'. If I change the variable to the following 'var_PrimaryKeyFrmName = MachineName' it works correctly, but I need this to be automated (use the var_PrimaryKey value to get it). I've tried changing the type of variable to avail.

Can anyone shed any light as to what I'm doing wrong? Thanks very much!
 
Perhaps this ?
var_PrimaryKeyFrmName = Me.Controls(var_PrimaryKey)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top