G
Guest
Hi,
I am using a hidden listbox to pass a resulting value from a SELECT query to
a cell in an Excel spreadsheet when the user opens it.
For one spreadsheet it works perfectly. The values are displayed in the
cell. The code I am using is shown below.
strSQLMYR643 = "SELECT SUM([MYRNonProject].[" &
Forms!frmSelectCC!cmbCostCentre.Value & "]) AS NonPrjMYR FROM [MYRNonProject]
WHERE([MYRNonProject].[GLCode]='F6430000' OR
[MYRNonProject].[GLCode]='E6430000')"
Me!lstMYR643.RowSourceType = "Table/Query"
Me.lstMYR643.RowSource = strSQLMYR643
objActiveWksh.cells(3, 20) = Me.lstMYR643.ItemData(0)
The same code in the other form (a different query of course) displays
values in the listbox (When listbox is set to visible), but does not pass
the value to the cell in the Excel Spreadsheet.
strSQLMYRNonPrj = "SELECT [MYRNonProject].[" &
Forms!frmSelectCC!cmbCostCentre.Value & "] FROM [MYRNonProject]
WHERE([MYRNonProject].[GLCode]='" & Forms!frmSelectGLC!txtGLCode.Value & "')"
Me!lstFCMYRNonPrj.RowSourceType = "Table/Query"
Me.lstFCMYRNonPrj.RowSource = strSQLMYRNonPrj
objActiveWksh.cells(3, 10) = Me.lstFCMYRNonPrj.ItemData(0)
Is there anything I need to know about this. Why doesn't the same code work
on different accasions?
It's driving me nuts. Please help me.
Toyfixer
I am using a hidden listbox to pass a resulting value from a SELECT query to
a cell in an Excel spreadsheet when the user opens it.
For one spreadsheet it works perfectly. The values are displayed in the
cell. The code I am using is shown below.
strSQLMYR643 = "SELECT SUM([MYRNonProject].[" &
Forms!frmSelectCC!cmbCostCentre.Value & "]) AS NonPrjMYR FROM [MYRNonProject]
WHERE([MYRNonProject].[GLCode]='F6430000' OR
[MYRNonProject].[GLCode]='E6430000')"
Me!lstMYR643.RowSourceType = "Table/Query"
Me.lstMYR643.RowSource = strSQLMYR643
objActiveWksh.cells(3, 20) = Me.lstMYR643.ItemData(0)
The same code in the other form (a different query of course) displays
values in the listbox (When listbox is set to visible), but does not pass
the value to the cell in the Excel Spreadsheet.
strSQLMYRNonPrj = "SELECT [MYRNonProject].[" &
Forms!frmSelectCC!cmbCostCentre.Value & "] FROM [MYRNonProject]
WHERE([MYRNonProject].[GLCode]='" & Forms!frmSelectGLC!txtGLCode.Value & "')"
Me!lstFCMYRNonPrj.RowSourceType = "Table/Query"
Me.lstFCMYRNonPrj.RowSource = strSQLMYRNonPrj
objActiveWksh.cells(3, 10) = Me.lstFCMYRNonPrj.ItemData(0)
Is there anything I need to know about this. Why doesn't the same code work
on different accasions?
It's driving me nuts. Please help me.
Toyfixer