Type Mismatch RecordSource

B

Bryan

Access 2003

Help. Can not set the subform recordsource. Returns error "Type Mismatch"

Dim rs As DAO.Recordset
Dim qdf As DAO.QueryDef
Set qdf = CurrentDb.QueryDefs("QRY_DUPLICATE")
qdf.Parameters("prmDate") = txtstartDate
Set rs = qdf.OpenRecordset

msgbox rs.recordcount <---'Quick test returns the expected rows

Me.frmsubhours.Form.RecordSource = rs <----Type Mismatch
 
R

RoyVidar

Bryan said:
Access 2003

Help. Can not set the subform recordsource. Returns error "Type
Mismatch"

Dim rs As DAO.Recordset
Dim qdf As DAO.QueryDef
Set qdf = CurrentDb.QueryDefs("QRY_DUPLICATE")
qdf.Parameters("prmDate") = txtstartDate
Set rs = qdf.OpenRecordset

msgbox rs.recordcount <---'Quick test returns the expected rows

Me.frmsubhours.Form.RecordSource = rs <----Type Mismatch

If you wish to assign the recordset, you need

Set Me.frmsubhours.Form.RecordSet = rs
 
E

Evi

Bryan said:
Access 2003

Help. Can not set the subform recordsource. Returns error "Type Mismatch"

Dim rs As DAO.Recordset
Dim qdf As DAO.QueryDef
Set qdf = CurrentDb.QueryDefs("QRY_DUPLICATE")
qdf.Parameters("prmDate") = txtstartDate
Set rs = qdf.OpenRecordset

msgbox rs.recordcount <---'Quick test returns the expected rows

Me.frmsubhours.Form.RecordSource = rs <----Type Mismatch
Four things that have given me Type Mismatch are
1.Missing Reference (open any Module and go to Tools References and see if
any are marked as missing)
2.I've had a home made Function in a query which relies on something in
another cell being a particular format but one of the cells was blank. eg
the Function was something like
Function MyFunction (dtDateField as Date, intCountField As Integer)
but it was used in a query where the dtDateField was sometimes blank.
3.A formula replaced cell contents with "" but the Table Field had Allow
Zero Length set to No.
4.One of my fields had a name which was also a function in Access (Eval in
this case). It seemed to work fine but suddenly threw up a Type Mismatch
when I made a report based on the table or tried to sort a query based on
that field.
 

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