Form opens with no records. (1 Viewer)

cliftonx

Registered User.
Local time
Yesterday, 20:44
Joined
Mar 4, 2010
Messages
27
After setting the Record Source to the underling source table and using the CreateQueryDef definition to define and execute the query. The form opens up with no records from the query. The following is the code that I am using. What am I doing wrong?

Dim dbs As DAO.Database
Dim qdf As DAO.QueryDef
Dim rst As DAO.Recordset
Dim qdfpass As QueryDef
Dim resource As String

Me.RecordSource = "dbo_tblDevsWithPartSpecs"

Set dbs = CurrentDb

'Create temporary query definition
Set qdfpass = dbs.CreateQueryDef("")

With qdfpass
.Connect = "ODBC;DRIVER=SQL Server;SERVER=opd-s-sql1;Trusted_Connection=Yes;DATABASE=OPD_ICE_DOTNET"
.sql = "Exec spDevsWithPartSpecs '" & Forms!frmiimain.cboJobNumber & "' "
.ReturnsRecords = True

'Open a Recordset based on the parameter query
Set rst = .OpenRecordset()

End With

Forms!frmiimain.Form.Requery

End Sub
 

Minty

AWF VIP
Local time
Today, 02:44
Joined
Jul 26, 2013
Messages
10,371
You aren't setting the form record source to the recordset you are setting up?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 09:44
Joined
May 7, 2009
Messages
19,231
from which Event are you executing the code?
does the spelling here correct:

Forms!frmiimain.cboJobNumber

is the cboJobNumber on this same form?

Me.Recordset = .OpenRecordset()
 

Gasman

Enthusiastic Amateur
Local time
Today, 02:44
Joined
Sep 21, 2011
Messages
14,265
Data entry set to Yes ?????
 

Users who are viewing this thread

Top Bottom