I'm going nuts trying to set a Data Control to a Query Parameter. I have
tried code from VB4 help files, from VB Programmers Journal and from MS
KnowledgeBase Q142938. Nothing works. I am using VB4 Pro with Access 97
database with DAO 3.5 loaded. The following code works best:
Private Sub cmdAdd_Click()
Dim db As Database
Dim rs As Recordset
Dim qd As QueryDef
Dim prm As Parameter
Set db = OpenDatabase(Data1.DatabaseName)
Set qd = db.QueryDefs("newTitle")
For Each prm In qd.Parameters
prm.Value = InputBox("Enter value for " & prm.Name)
Next prm
Set rs = qd.OpenRecordset(qd, dbOpenDynaset)
Set Data1.Recordset = rs ' ERROR HERE
Data1.Refresh
End Sub
The error is type 13 'Type Mismatch'. Both rs and Data1.recordset are type
2 dynasets. rs is correctly set as an object.
Would really appreciate any help! Thanks.