0
votes

I had a form with some VB code that was using Access 2003. Recently we wanted to use the same form as a small front end interface for another database that has a SQL Server backend. However, the file type for this project in Access is .adp and not all of the vb code is working properly. If you could help me fix the bugs in this code:

Private Sub SurveyNameCombo_AfterUpdate()

Dim db_CFC As DAO.Database
Set db_CFC = CurrentDb

Dim rst As DAO.Recordset, query As String, count As Integer
query = "SELECT DISTINCT SurveyID FROM tbl_SurveyMeta WHERE SurveyName = " & Chr(34) & Me.SurveyNameCombo.Value & Chr(34)

Set rst = db_CFC.OpenRecordset(query)
count = rst.RecordCount

If count > 1 Then
    Me.SurveyIDCombo.RowSource = query
Else
    rst.MoveFirst
    Me.SurveyIDCombo.Value = rst.Fields(0).Value
    Call SurveyIDCombo_AfterUpdate
End If

End Sub

It is throwing errors in the for the DAO.Database and DAO.Recordset.

Thank you for your help!

1
It highlights the first row and says "User-defined type not defined" - Martian
There is never a compelling reason to convert any existing Access app to ADP. If any development should ever be done with an ADP (it looks like the format is going the way of the dinosaur in the next version of Access), it should only be NEW development, because very little converts directly from an MDB/ACCDB. - David-W-Fenton

1 Answers

0
votes

The error message "User-defined type not defined" on a line such as this ...

Dim db_CFC As DAO.Database

... means your application doesn't include a reference to the Microsoft DAO Object Library.

Open a code module, then check from the main menu in the VBE editor: Tools->References

Ordinarily the cure would be to place a check mark in the box next to Microsoft DAO Object Library, then click OK. However, your application is an ADP, and I don't know whether DAO can even be used in ADP. You can try. :-)

Sorry I can't tell you more. I quit using ADP a few years ago. Instead I use the MDB format with ODBC links to SQL Server database objects. Perhaps you could consider the same approach if you're unable to get the ADP version working as you need.