Binding Forms With Ado

italiancholo

New member
Local time
Today, 20:45
Joined
May 14, 2007
Messages
5
Hi there,
I am having a stupid problem I can't solve. I am developing a database with access 2003 and I want to late bind the form to an ADO recordset via a stored query (the reason for this is that I read that when i will move to SQL server just using stored queries and no queries in code will be easier).
The query itself works fine, the code also works fine until I get to the instruction:

Set Me.Recordset = rs

when I get there I am prompted with the dialog message box "Enter parameter value" referring to the primary key of the table where the stored query gets the recordset from. I click ok and the form shows up and works correctly. Simply I need not to have the damn message box suppressed.

Thank you for any help you can give me! I am quite desperate.

Here is the stored query statement (query being called "QryCONN_OfferteClienti"):
SELECT OfferteClienti.*
FROM OfferteClienti;

here is the code in the form_open event:

Private Sub Form_Open(Cancel As Integer)
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset

'Use the ADO connection that Access uses
Set cn = CurrentProject.AccessConnection

'Create an instance of the ADO Recordset class, and
'set its properties
Set rs = New ADODB.Recordset
With rs
Set .ActiveConnection = cn
.CursorLocation = adUseClient
.Source = "QryCONN_OfferteClienti"
.LockType = adLockOptimistic
.CursorType = adOpenKeyset
.Open
End With
'Set the form's Recordset property to the ADO recordset
Set Me.Recordset = rs

DoCmd.GoToRecord , , acNewRec

Set rs = Nothing
Set cn = Nothing
End Sub
 
Remove the quotation marks

If QryCONN_OfferteClienti is a string variable, try removing the quotation marks here:

.Source = "QryCONN_OfferteClienti"
 
forms can only be bound to tables or queries so why not set the record source for the form to

"QryCONN_OfferteClienti"
 

Users who are viewing this thread

Back
Top Bottom