A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Recordset Issues



 
 
Thread Tools Display Modes
  #1  
Old June 8th, 2004, 10:51 PM
GregK
external usenet poster
 
Posts: n/a
Default Recordset Issues

I have the following code to run some SQL in the load event. The SQL should return 1 row with 1 column.

Dim ID As Integer
Dim Room As New ADODB.Recordset
Dim cnn As Object
Dim cmd As New ADODB.Command
Dim SQLState As String

ID = [Forms]![PatronSelection]![Combo0]
SQLState = "SELECT ReservationData.RoomCode FROM ReservationData WHERE (((ReservationData.HostTable) = ID)) GROUP BY ReservationData.RoomCode;"
Set cnn = New ADODB.Connection
Set cnn = CurrentProject.Connection
'Set Room = New ADODB.Recordset

Room.Open SQLState, cnn, adOpenStatic, adCmdText

I get the following error:
- No value given for one or more required parameters.

I am trying to set a combobox with a value that will match the records in a subform.

Thank you in advance with any help.
  #2  
Old June 9th, 2004, 04:35 AM
Van T. Dinh
external usenet poster
 
Posts: n/a
Default Recordset Issues

You need to resolve the VBA Variable ID to explicit value
since the JET engine does not know the VBA Varaible.

Try (****untested****):

Dim Room As New ADODB.Recordset
Dim cnn As Object
Dim cmd As New ADODB.Command
Dim SQLState As String

SQLState = "SELECT ReservationData.RoomCode FROM " & _
"ReservationData WHERE (((ReservationData.HostTable)= " & _
[Forms]![PatronSelection]![Combo0] & ")) " & _
"GROUP BY ReservationData.RoomCode"

'Debug.Print SQLState
Set cnn = New ADODB.Connection
Set cnn = CurrentProject.Connection
'Set Room = New ADODB.Recordset

Room.Open SQLState, cnn, adOpenStatic, adCmdText

HTH
Van T. Dinh
MVP (Access)




-----Original Message-----
I have the following code to run some SQL in the load

event. The SQL should return 1 row with 1 column.

Dim ID As Integer
Dim Room As New ADODB.Recordset
Dim cnn As Object
Dim cmd As New ADODB.Command
Dim SQLState As String

ID = [Forms]![PatronSelection]![Combo0]
SQLState = "SELECT ReservationData.RoomCode FROM

ReservationData WHERE (((ReservationData.HostTable) = ID))
GROUP BY ReservationData.RoomCode;"
Set cnn = New ADODB.Connection
Set cnn = CurrentProject.Connection
'Set Room = New ADODB.Recordset

Room.Open SQLState, cnn, adOpenStatic, adCmdText

I get the following error:
- No value given for one or more required parameters.

I am trying to set a combobox with a value that will

match the records in a subform.

Thank you in advance with any help.
.

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 05:13 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.