What version of Access? Database is a DAO object, and Access 2000 and 2002
use ADO by default.
With any code module open, select Tools | References from the menu bar,
scroll through the list of available references until you find the one for
Microsoft DAO 3.6 Object Library, and select it. If you're not going to be
using ADO, uncheck the reference to Microsoft ActiveX Data Objects 2.x
Library
If you have both references, you'll find that you'll need to "disambiguate"
certain declarations, because objects with the same names exist in the 2
models. For example, to ensure that you get a DAO recordset, you'll need to
use Dim rst as DAO.Recordset (to guarantee an ADO recordset, you'd use Dim
rst As ADODB.Recordset)
The list of objects with the same names in the 2 models is Connection,
Error, Errors, Field, Fields, Parameter, Parameters, Property, Properties
and Recordset
--
Doug Steele, Microsoft Access MVP
(No private e-mails, please)
Alp Bekisoglu said:
Hi Doug,
Here's the code behind:
Private Sub Form_Open(Cancel As Integer)
Dim dbs As Database
Dim rst As Recordset
On Error GoTo Form_Open_Err
DoCmd.SelectObject acForm, "Menu", True
DoCmd.Minimize
DoCmd.Hourglass False
Set dbs = CurrentDb()
Set rst = dbs.OpenRecordset("main") 'this is the master table that
program checks if there are any records
If rst.RecordCount = 0 Then
rst.AddNew
MsgBox "...here's a greeting message to the user that spans over a few
rows......"
DoCmd.OpenForm "Main", , , , , acDialog '<<< this is the main form
that is supposed to be opened when there are no records
DoCmd.OpenForm "Main_ya_table1", , , , , acDialog
End If
rst.Close
dbs.Close
Me.Filter = "[MenuNo] = 0 AND [Argument] = 'Default' "
Me.FilterOn = True
Form_Open_Exit:
Exit Sub
Form_Open_Err:
MsgBox Err.description
Resume Form_Open_Exit
End Sub
Rest of the code is very similar to the typical wizard generated switchboard
menu code, the fill function, etc.
Hope this can give a clue. Let me know if you'd rather have a look at the
complete code behind the main menu form.
Thanks,
Alp
Douglas J. Steele said:
Without seeing the code in question, it's pretty much impossible for anyone
to help.
Copy the VBA code that's failing, indicating (if possible) what line causes
the error.