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!
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!