Hi. I’m fairly new to using SQL server with Access and have a question about opening forms. I have two forms, one that is used to set criteria for opening the second form which views the data. The startup form is called frmGaugeStartup, and the main form is called frmGaugeLog. I want to use two criteria from frmGaugeStartup to open frmGaugeLog: Date and Location.
The frmGaugeLog’s data source is based on an SQL statement that uses two tables, TransGauge and zInfoTanks. TransGauge holds the transactional information and zInfoTanks has the location information.
The SQL record source for frmGaugeLog looks like this:
SELECT TransGauge.*, zInfoTanks.T_LOC_ABBR
FROM TransGauge INNER JOIN
zInfoTanks ON TransGauge.GA_Tank = zInfoTanks.T_ID
ORDER BY zInfoTanks.T_INDEX
The problem I seem to be having is that I can’t open the form referencing the two criteria fields from frmGaugeStartup using a traditional docmd.openform command. When I use the following I get an error:
Dim stLinkCriteria As String
stLinkCriteria = "TransGauge.[GA_Date] = '" & Date1 & "' _
AND zInfoTanks.[T_LOC_ABBR] = '" & Ref1 & "'"
DoCmd.OpenForm "frmGaugeLog", , , stLinkCriteria, acFormEdit, acWindowNormal
The error I get says the following:
Run-time error ‘107’:
The column prefix ‘zInfoTanks’ does not match with the table name or alias name used in the query.
Am I going about this wrong? If I don’t use linked tables as the source for frmGaugeLog and only use the table TransGauge then I’m able to open ok, but without being able to use the Location criteria, as that is stored on the zInfoTanks table.
Any help or pointers would be greatly appreciated and I can stop pulling out my hair. Thanks in advance.
James
The frmGaugeLog’s data source is based on an SQL statement that uses two tables, TransGauge and zInfoTanks. TransGauge holds the transactional information and zInfoTanks has the location information.
The SQL record source for frmGaugeLog looks like this:
SELECT TransGauge.*, zInfoTanks.T_LOC_ABBR
FROM TransGauge INNER JOIN
zInfoTanks ON TransGauge.GA_Tank = zInfoTanks.T_ID
ORDER BY zInfoTanks.T_INDEX
The problem I seem to be having is that I can’t open the form referencing the two criteria fields from frmGaugeStartup using a traditional docmd.openform command. When I use the following I get an error:
Dim stLinkCriteria As String
stLinkCriteria = "TransGauge.[GA_Date] = '" & Date1 & "' _
AND zInfoTanks.[T_LOC_ABBR] = '" & Ref1 & "'"
DoCmd.OpenForm "frmGaugeLog", , , stLinkCriteria, acFormEdit, acWindowNormal
The error I get says the following:
Run-time error ‘107’:
The column prefix ‘zInfoTanks’ does not match with the table name or alias name used in the query.
Am I going about this wrong? If I don’t use linked tables as the source for frmGaugeLog and only use the table TransGauge then I’m able to open ok, but without being able to use the Location criteria, as that is stored on the zInfoTanks table.
Any help or pointers would be greatly appreciated and I can stop pulling out my hair. Thanks in advance.
James