What's wrong with my code?

G

Guest

Sub QueryToExcel()
' Send Monthly Output results to Excel

Dim rstMonthlyOutput As ADODB.Recordset
Dim objXL As Excel.Application
Dim objWS As Excel.Worksheet
Dim fld As ADODB.Field
Dim intCol As Integer
Dim intRow As Integer

Set rstMonthlyOutput = New ADODB.Recordset

' This is where I keep getting an error
'Run-time error '-2147217900 (80040e14):
'Invalid SQL statement; expected 'DELETE', 'INSERT', 'PROCEDURE',
''SELECT', or 'UPDATE'.

rstMonthlyOutput.Open "MonthlyOutput", CurrentProject.Connection

' Launch Excel
Set objXL = New Excel.Application
' Create new worksheet
objXL.Workbooks.Add
Set objWS = objXL.ActiveSheet

' Copy Field names
For intCol = 0 To rstMonthlyOutput.Fields.Count - 1
Set fld = rstMonthlyOutput.Fields(intCol)
objWS.Cells(1, intCol + 1) = fld.Name
Next intCol
' Copy data
intRow = 2
Do Until rstMonthlyOutput.EOF
For intCol = 0 To rstMonthlyOutput.Fields.Count - 1
objWS.Cells(intRow, intCol + 1) = _
rstMonthlyOutput.Fields(intCol).Value
Next intCol
rstMonthlyOutput.MoveNext
intRow = intRow + 1
Loop

' Make worksheet visible
objXL.Visible = True

End Sub
 
B

Brendan Reynolds

There is nothing obviously wrong with that code - assuming, of course, that
'MonthlyOutput' is the name of a table or query in the current database. If
'MonthlyOutput' is a query, can you open the query in datasheet view without
error?
 
G

Guest

Yes. That is what is so puzzling to me. I can open the query and run it
without any problem. The only problem occurs when I try to open it with the
VBA code. Also, the code works perfectly with every other query except this
one!
 
B

Brendan Reynolds

Well, it would seem that the problem must lie in one of two places - the
name, or the SQL. The fact that you can open the query in datasheet view
would seem to indicate that the problem isn't in the SQL, but then again I'm
not completely sure that there might not be something that would work via
the UI (which I believe uses DAO behind the scenes) but not work when
executed via ADO. Does the query use the LIKE operator with the JET
wildcards '?' or '*' for example? What if you create a copy of the query
with a different name and change the code to use that name? Do you still get
the error? If so, it would seem that the error must lie in the SQL. If that
seems to be the case, could you post the SQL?
 
B

Brendan Reynolds

BTW: You could also try using the adCmdStoredProc keyword to explicitly
specify that the source is a saved query ...

Public Sub TestSub()

Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
rst.Open "qryTest", CurrentProject.Connection, , , adCmdStoredProc
Debug.Print rst.Fields(0)
rst.Close

End Sub
 
G

Guest

When I use your suggestion

rst.Open "qryTest", CurrentProject.Connection, , , adCmdStoredProc

I get an error back reading "Too few parameters. Expected 1." Did I mention
that I'm using Access 2000?
 
G

Guest

Oh, here's the SQL:

SELECT "10315" AS FROM_CC_NBR, FinalAllocationPrintSIDES.CCOUT AS TO_CC_NBR,
Sum(FinalAllocationPrintSIDES.SidesToCC) AS ACTUAL_UNITS
FROM FinalAllocationPrintSIDES
GROUP BY "10315", FinalAllocationPrintSIDES.CCOUT
HAVING (((Sum(FinalAllocationPrintSIDES.SidesToCC))>0));

I actually didn't write the SQL. I inherited it in design mode. I'm a little
suspicious of the first Field definition in the design mode because it
appears to both re-name the field and set a search criteria. Is that OK? In
other words, it selects those items in the field that are numbered "10315"
and names the field FROM_CC_NBR. The other stuff is pretty straight forward.
It selects the second and third fields all from the same table, summing the
third, grouping the data by the first and second, where the third field is
greater than zero. The third field is a calculated field that multiplies two
others.
 
G

Guest

BTW I just checked using your TestSub() and it worked fine with other
queries. It is giving me those errors only in the MonthlyOutput query, so I
think there probably is somehting wrong with the query that allows it to work
in Jet but not with ADO! Do you have any suggestions to "convert" it to
something recognizable in ADO?
 
B

Brendan Reynolds

Your query worked without error for me, Ray. Here's the code I used to test
it. Note that I'm assuming here that 'FinalAllocationPrintSIDES' is the name
of a table. If it isn't, if 'FinalAllocationPrintSIDES' is another query,
then it is possible that the problem may actually lie in the SQL of *that*
query.

Public Sub CreateTable()

Dim strSQL As String

strSQL = "CREATE TABLE FinalAllocationPrintSIDES (CCOUT int, SidesToCC
int)"
CurrentProject.Connection.Execute strSQL, , adCmdText

End Sub

Public Sub FillTable()

Dim lngLoop As Long
Dim strSQL As String

For lngLoop = 1 To 10
strSQL = "INSERT INTO FinalAllocationPrintSIDES (CCOUT, SidesToCC)
VALUES (" & lngLoop & ", " & lngLoop & ")"
CurrentProject.Connection.Execute strSQL, , adCmdText
Next lngLoop

End Sub

Public Sub CreateQuery()

Dim strSQL As String
Dim db As DAO.Database
Dim qdf As DAO.QueryDef

strSQL = "SELECT ""10315"" AS FROM_CC_NBR,
FinalAllocationPrintSIDES.CCOUT AS TO_CC_NBR, " & _
"Sum(FinalAllocationPrintSIDES.SidesToCC) As ACTUAL_UNITS " & _
"FROM FinalAllocationPrintSIDES " & _
"GROUP BY ""10315"", FinalAllocationPrintSIDES.CCOUT " & _
"HAVING (((Sum(FinalAllocationPrintSIDES.SidesToCC))>0));"
Set db = CurrentDb
Set qdf = db.CreateQueryDef("MonthlyOutput", strSQL)

End Sub

Public Sub ReadData()

Dim rst As ADODB.Recordset

Set rst = New ADODB.Recordset
rst.Open "MonthlyOutput", CurrentProject.Connection, , , adCmdStoredProc
Do Until rst.EOF
Debug.Print rst.Fields("FROM_CC_NBR"), rst.Fields("TO_CC_NBR"),
rst.Fields("ACTUAL_UNITS")
rst.MoveNext
Loop
rst.Close

End Sub
 
G

Guest

First,

I'm trying to reproduce your test.

what is

VALUES (" & lngLoop & ", " & lngLoop & ")"

It returns a syntax error.

Second,

Sorry about the bad naming practices, but as I mentioned, I inherited much
of this. I'm trying to rename objects, but as you know, I have to do it with
care for references and dependencies.

FinalAllocationPrintSIDES is a query:

SELECT SumOfSidesbyMaster.[Master-Sub], FinalSystemAllocations.CCOUT,
FinalSystemAllocations.PERCOUT, SumOfSidesbyMaster.SumOfSideCount,
[PERCOUT]*[SumOfSideCount] AS SidesToCC
FROM SumOfSidesbyMaster LEFT JOIN FinalSystemAllocations ON
SumOfSidesbyMaster.[Master-Sub] = FinalSystemAllocations.[Master-Sub];

It gets worse -

SumOfSidesbyMaster is also a query, and FinalSystemAllocations is also a
query.

SumOfSidesbyMaster:

SELECT tblPrintData.[Master-Sub], Sum(tblPrintData.SideCount) AS
SumOfSideCount
FROM tblPrintData
WHERE (((tblPrintData.Month)=[Forms]![MainForm]![cboSelectMonth]))
GROUP BY tblPrintData.[Master-Sub];

FinalSystemAllocations:

SELECT MasterSubInfo.[Master-Sub], STATREPORTCURRENTMONTH.StatReportName,
MasterSubInfo.AllocType, AllocData.CostCenter, AllocData.Percent,
STATREPORTCURRENTMONTH.ToCC, STATREPORTCURRENTMONTH.Percentage,
IIf([costcenter] Is Null,[ToCC],[CostCenter]) AS CCOUT, IIf([Percent] Is
Null,[Percentage],[Percent]) AS PERCOUT
FROM (MasterSubInfo LEFT JOIN STATREPORTCURRENTMONTH ON
MasterSubInfo.AllocType = STATREPORTCURRENTMONTH.StatReportName) LEFT JOIN
AllocData ON MasterSubInfo.[Master-Sub] = AllocData.[Master-Sub];

MasterSubInfo, and AllocData are tables
 
B

Brendan Reynolds

There you go ...

WHERE (((tblPrintData.Month)=[Forms]![MainForm]![cboSelectMonth]))

When you open a query like that in the UI, Access takes care of resolving
the parameter for you, but when you open a recordset programatically, you
have to assign a value to the parameter programatically too. It's not
difficult to do when you have just one query to deal with but I don't think
I've ever done it in a situation like yours, where you have multiple levels
of nested queries, so I'm not sure how much that is going to complicate
matters. Here's an example with one query ...

Here's the SQL for the parameter query ...

SELECT tblTest.*
FROM tblTest
WHERE (((tblTest.TestID)=[TestParam]));

And here's the code that opens a recordset on the above query ...

Public Sub OpenParamQuery()

Dim cmd As ADODB.Command
Dim prm As ADODB.Parameter
Dim rst As ADODB.Recordset

Set cmd = New ADODB.Command
With cmd
Set .ActiveConnection = CurrentProject.Connection
.CommandText = "qryTest"
.CommandType = adCmdStoredProc
End With
Set prm = cmd.CreateParameter("[TestParam]", adInteger)
cmd.Parameters.Append prm
cmd.Parameters("[TestParam]").Value = 1
Set rst = cmd.Execute
Do Until rst.EOF
Debug.Print rst.Fields(0)
rst.MoveNext
Loop
rst.Close

End Sub

Personally, I think I'd be inclined to not try to use these multiple nested
queries but write a new one for programatic use. But perhaps, now that we've
pinned down the problem, someone else may have another suggestion.

Not sure why you're having a problem with VALUES, but then I've been
assuming all along an MDB app and MDB data, but I don't think you ever
explicitly stated that. Is the app an MDB or an ADP? And is the data a JET
(MDB) database, or SQL Server, or something else?

Here's a link to the on-line help topic on the INSERT statement, including
the VALUES keyword ...
http://office.microsoft.com/en-gb/assistance/HP010322451033.aspx

--
Brendan Reynolds
Access MVP


Ray S. said:
First,

I'm trying to reproduce your test.

what is

VALUES (" & lngLoop & ", " & lngLoop & ")"

It returns a syntax error.

Second,

Sorry about the bad naming practices, but as I mentioned, I inherited much
of this. I'm trying to rename objects, but as you know, I have to do it
with
care for references and dependencies.

FinalAllocationPrintSIDES is a query:

SELECT SumOfSidesbyMaster.[Master-Sub], FinalSystemAllocations.CCOUT,
FinalSystemAllocations.PERCOUT, SumOfSidesbyMaster.SumOfSideCount,
[PERCOUT]*[SumOfSideCount] AS SidesToCC
FROM SumOfSidesbyMaster LEFT JOIN FinalSystemAllocations ON
SumOfSidesbyMaster.[Master-Sub] = FinalSystemAllocations.[Master-Sub];

It gets worse -

SumOfSidesbyMaster is also a query, and FinalSystemAllocations is also a
query.

SumOfSidesbyMaster:

SELECT tblPrintData.[Master-Sub], Sum(tblPrintData.SideCount) AS
SumOfSideCount
FROM tblPrintData
WHERE (((tblPrintData.Month)=[Forms]![MainForm]![cboSelectMonth]))
GROUP BY tblPrintData.[Master-Sub];

FinalSystemAllocations:

SELECT MasterSubInfo.[Master-Sub], STATREPORTCURRENTMONTH.StatReportName,
MasterSubInfo.AllocType, AllocData.CostCenter, AllocData.Percent,
STATREPORTCURRENTMONTH.ToCC, STATREPORTCURRENTMONTH.Percentage,
IIf([costcenter] Is Null,[ToCC],[CostCenter]) AS CCOUT, IIf([Percent] Is
Null,[Percentage],[Percent]) AS PERCOUT
FROM (MasterSubInfo LEFT JOIN STATREPORTCURRENTMONTH ON
MasterSubInfo.AllocType = STATREPORTCURRENTMONTH.StatReportName) LEFT JOIN
AllocData ON MasterSubInfo.[Master-Sub] = AllocData.[Master-Sub];

MasterSubInfo, and AllocData are tables


Brendan Reynolds said:
Your query worked without error for me, Ray. Here's the code I used to
test
it. Note that I'm assuming here that 'FinalAllocationPrintSIDES' is the
name
of a table. If it isn't, if 'FinalAllocationPrintSIDES' is another query,
then it is possible that the problem may actually lie in the SQL of
*that*
query.

Public Sub CreateTable()

Dim strSQL As String

strSQL = "CREATE TABLE FinalAllocationPrintSIDES (CCOUT int,
SidesToCC
int)"
CurrentProject.Connection.Execute strSQL, , adCmdText

End Sub

Public Sub FillTable()

Dim lngLoop As Long
Dim strSQL As String

For lngLoop = 1 To 10
strSQL = "INSERT INTO FinalAllocationPrintSIDES (CCOUT,
SidesToCC)
VALUES (" & lngLoop & ", " & lngLoop & ")"
CurrentProject.Connection.Execute strSQL, , adCmdText
Next lngLoop

End Sub

Public Sub CreateQuery()

Dim strSQL As String
Dim db As DAO.Database
Dim qdf As DAO.QueryDef

strSQL = "SELECT ""10315"" AS FROM_CC_NBR,
FinalAllocationPrintSIDES.CCOUT AS TO_CC_NBR, " & _
"Sum(FinalAllocationPrintSIDES.SidesToCC) As ACTUAL_UNITS " & _
"FROM FinalAllocationPrintSIDES " & _
"GROUP BY ""10315"", FinalAllocationPrintSIDES.CCOUT " & _
"HAVING (((Sum(FinalAllocationPrintSIDES.SidesToCC))>0));"
Set db = CurrentDb
Set qdf = db.CreateQueryDef("MonthlyOutput", strSQL)

End Sub

Public Sub ReadData()

Dim rst As ADODB.Recordset

Set rst = New ADODB.Recordset
rst.Open "MonthlyOutput", CurrentProject.Connection, , ,
adCmdStoredProc
Do Until rst.EOF
Debug.Print rst.Fields("FROM_CC_NBR"), rst.Fields("TO_CC_NBR"),
rst.Fields("ACTUAL_UNITS")
rst.MoveNext
Loop
rst.Close

End Sub
 
G

Guest

WOW,

I'm going to have to digest this a little bit.

Set rst = cmd.Execute
returns an error - too few parameters, 2 expected.

Yes, its MDB app and JET data.

My Reference Libraries are:
VBA
Access 9 OL
OLE Auto
ADO 2.7 OL
ActiveX Data Objects 2.7 for DLL & Security
DAO 3.6 OL
Excel 9 OL

It sure would be nice if I could get your examples to work.


Brendan Reynolds said:
There you go ...

WHERE (((tblPrintData.Month)=[Forms]![MainForm]![cboSelectMonth]))

When you open a query like that in the UI, Access takes care of resolving
the parameter for you, but when you open a recordset programatically, you
have to assign a value to the parameter programatically too. It's not
difficult to do when you have just one query to deal with but I don't think
I've ever done it in a situation like yours, where you have multiple levels
of nested queries, so I'm not sure how much that is going to complicate
matters. Here's an example with one query ...

Here's the SQL for the parameter query ...

SELECT tblTest.*
FROM tblTest
WHERE (((tblTest.TestID)=[TestParam]));

And here's the code that opens a recordset on the above query ...

Public Sub OpenParamQuery()

Dim cmd As ADODB.Command
Dim prm As ADODB.Parameter
Dim rst As ADODB.Recordset

Set cmd = New ADODB.Command
With cmd
Set .ActiveConnection = CurrentProject.Connection
.CommandText = "qryTest"
.CommandType = adCmdStoredProc
End With
Set prm = cmd.CreateParameter("[TestParam]", adInteger)
cmd.Parameters.Append prm
cmd.Parameters("[TestParam]").Value = 1
Set rst = cmd.Execute
Do Until rst.EOF
Debug.Print rst.Fields(0)
rst.MoveNext
Loop
rst.Close

End Sub

Personally, I think I'd be inclined to not try to use these multiple nested
queries but write a new one for programatic use. But perhaps, now that we've
pinned down the problem, someone else may have another suggestion.

Not sure why you're having a problem with VALUES, but then I've been
assuming all along an MDB app and MDB data, but I don't think you ever
explicitly stated that. Is the app an MDB or an ADP? And is the data a JET
(MDB) database, or SQL Server, or something else?

Here's a link to the on-line help topic on the INSERT statement, including
the VALUES keyword ...
http://office.microsoft.com/en-gb/assistance/HP010322451033.aspx

--
Brendan Reynolds
Access MVP


Ray S. said:
First,

I'm trying to reproduce your test.

what is

VALUES (" & lngLoop & ", " & lngLoop & ")"

It returns a syntax error.

Second,

Sorry about the bad naming practices, but as I mentioned, I inherited much
of this. I'm trying to rename objects, but as you know, I have to do it
with
care for references and dependencies.

FinalAllocationPrintSIDES is a query:

SELECT SumOfSidesbyMaster.[Master-Sub], FinalSystemAllocations.CCOUT,
FinalSystemAllocations.PERCOUT, SumOfSidesbyMaster.SumOfSideCount,
[PERCOUT]*[SumOfSideCount] AS SidesToCC
FROM SumOfSidesbyMaster LEFT JOIN FinalSystemAllocations ON
SumOfSidesbyMaster.[Master-Sub] = FinalSystemAllocations.[Master-Sub];

It gets worse -

SumOfSidesbyMaster is also a query, and FinalSystemAllocations is also a
query.

SumOfSidesbyMaster:

SELECT tblPrintData.[Master-Sub], Sum(tblPrintData.SideCount) AS
SumOfSideCount
FROM tblPrintData
WHERE (((tblPrintData.Month)=[Forms]![MainForm]![cboSelectMonth]))
GROUP BY tblPrintData.[Master-Sub];

FinalSystemAllocations:

SELECT MasterSubInfo.[Master-Sub], STATREPORTCURRENTMONTH.StatReportName,
MasterSubInfo.AllocType, AllocData.CostCenter, AllocData.Percent,
STATREPORTCURRENTMONTH.ToCC, STATREPORTCURRENTMONTH.Percentage,
IIf([costcenter] Is Null,[ToCC],[CostCenter]) AS CCOUT, IIf([Percent] Is
Null,[Percentage],[Percent]) AS PERCOUT
FROM (MasterSubInfo LEFT JOIN STATREPORTCURRENTMONTH ON
MasterSubInfo.AllocType = STATREPORTCURRENTMONTH.StatReportName) LEFT JOIN
AllocData ON MasterSubInfo.[Master-Sub] = AllocData.[Master-Sub];

MasterSubInfo, and AllocData are tables


Brendan Reynolds said:
Your query worked without error for me, Ray. Here's the code I used to
test
it. Note that I'm assuming here that 'FinalAllocationPrintSIDES' is the
name
of a table. If it isn't, if 'FinalAllocationPrintSIDES' is another query,
then it is possible that the problem may actually lie in the SQL of
*that*
query.

Public Sub CreateTable()

Dim strSQL As String

strSQL = "CREATE TABLE FinalAllocationPrintSIDES (CCOUT int,
SidesToCC
int)"
CurrentProject.Connection.Execute strSQL, , adCmdText

End Sub

Public Sub FillTable()

Dim lngLoop As Long
Dim strSQL As String

For lngLoop = 1 To 10
strSQL = "INSERT INTO FinalAllocationPrintSIDES (CCOUT,
SidesToCC)
VALUES (" & lngLoop & ", " & lngLoop & ")"
CurrentProject.Connection.Execute strSQL, , adCmdText
Next lngLoop

End Sub

Public Sub CreateQuery()

Dim strSQL As String
Dim db As DAO.Database
Dim qdf As DAO.QueryDef

strSQL = "SELECT ""10315"" AS FROM_CC_NBR,
FinalAllocationPrintSIDES.CCOUT AS TO_CC_NBR, " & _
"Sum(FinalAllocationPrintSIDES.SidesToCC) As ACTUAL_UNITS " & _
"FROM FinalAllocationPrintSIDES " & _
"GROUP BY ""10315"", FinalAllocationPrintSIDES.CCOUT " & _
"HAVING (((Sum(FinalAllocationPrintSIDES.SidesToCC))>0));"
Set db = CurrentDb
Set qdf = db.CreateQueryDef("MonthlyOutput", strSQL)

End Sub

Public Sub ReadData()

Dim rst As ADODB.Recordset

Set rst = New ADODB.Recordset
rst.Open "MonthlyOutput", CurrentProject.Connection, , ,
adCmdStoredProc
Do Until rst.EOF
Debug.Print rst.Fields("FROM_CC_NBR"), rst.Fields("TO_CC_NBR"),
rst.Fields("ACTUAL_UNITS")
rst.MoveNext
Loop
rst.Close

End Sub

--
Brendan Reynolds
Access MVP

Oh, here's the SQL:

SELECT "10315" AS FROM_CC_NBR, FinalAllocationPrintSIDES.CCOUT AS
TO_CC_NBR,
Sum(FinalAllocationPrintSIDES.SidesToCC) AS ACTUAL_UNITS
FROM FinalAllocationPrintSIDES
GROUP BY "10315", FinalAllocationPrintSIDES.CCOUT
HAVING (((Sum(FinalAllocationPrintSIDES.SidesToCC))>0));

I actually didn't write the SQL. I inherited it in design mode. I'm a
little
suspicious of the first Field definition in the design mode because it
appears to both re-name the field and set a search criteria. Is that
OK?
In
other words, it selects those items in the field that are numbered
"10315"
and names the field FROM_CC_NBR. The other stuff is pretty straight
forward.
It selects the second and third fields all from the same table, summing
the
third, grouping the data by the first and second, where the third field
is
greater than zero. The third field is a calculated field that
multiplies
two
others.

:


BTW: You could also try using the adCmdStoredProc keyword to
explicitly
specify that the source is a saved query ...

Public Sub TestSub()

Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
rst.Open "qryTest", CurrentProject.Connection, , , adCmdStoredProc
Debug.Print rst.Fields(0)
rst.Close

End Sub

--
Brendan Reynolds
Access MVP

message
Well, it would seem that the problem must lie in one of two places -
the
name, or the SQL. The fact that you can open the query in datasheet
view
would seem to indicate that the problem isn't in the SQL, but then
again
I'm not completely sure that there might not be something that would
work
via the UI (which I believe uses DAO behind the scenes) but not work
when
executed via ADO. Does the query use the LIKE operator with the JET
wildcards '?' or '*' for example? What if you create a copy of the
query
with a different name and change the code to use that name? Do you
still
get the error? If so, it would seem that the error must lie in the
SQL.
If
that seems to be the case, could you post the SQL?

--
Brendan Reynolds
Access MVP


Yes. That is what is so puzzling to me. I can open the query and
run
it
without any problem. The only problem occurs when I try to open it
with
the
VBA code. Also, the code works perfectly with every other query
except
this
one!

:

There is nothing obviously wrong with that code - assuming, of
course,
that
'MonthlyOutput' is the name of a table or query in the current
database.
If
'MonthlyOutput' is a query, can you open the query in datasheet
view
without
error?
 
G

Guest

OK Brendan, or whoever can respond to this, I've had some time to digest your
comments and to try to get your sample code to work. It did not. I indicated
where I had the problems running it, adding all my loaded reference libraries.

Beyond that, I figured out that the reference to the combo box buried deep
in nested queries was the problem. I removed it, and my code works to export
the query results to Excel. Now, here's the problem. I want to have the user
select a date from the combo box in my form to narrow the query results that
will go to Excel.

Here's my renewed query:

SELECT "10315" AS FROM_CC_NBR, qryFinalAllocationPrintSIDESCopyMO.CCOUT AS
TO_CC_NBR, Sum(qryFinalAllocationPrintSIDESCopyMO.SidesToCC) AS ACTUAL_UNITS,
SumOfSidesbyMasterCopyMO.Month
FROM qryFinalAllocationPrintSIDESCopyMO INNER JOIN SumOfSidesbyMasterCopyMO
ON qryFinalAllocationPrintSIDESCopyMO.[Master-Sub] =
SumOfSidesbyMasterCopyMO.[Master-Sub]
GROUP BY "10315", qryFinalAllocationPrintSIDESCopyMO.CCOUT,
SumOfSidesbyMasterCopyMO.Month

As I said, it works fine with my export to Excel function.

I have been trying to figure out your example to programmatically assign a
value to the parameter (as you suggested). Your example seems to assume
assigning a fixed value to the parameter, but my parameter is not fixed. The
value will be whatever the user selects for the combo box.

I need some help on how to assign that value.

There may be a simple internal function that allows me to set that value,
but I am not that knowledgeable about Access or VBA to easily figure it out.

Can anyone help?

I have not repeated the prior messages in this one to keep this clean, but
you can see my initial code and Brendan's suggestion above...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top