I have a switchboard (form) with a project name and number that is stored in a table (project_info).
The switchboard is the first form that opens (set in the startup options menu).
I have a form for users to enter the project name and number (called Project_details). This only needs to be entered once for the life of the database (until it is used for a new project).
If there is no project name or number in the table then the code that fetches the number onto the form comes up with an error because there is no recordset in the empty project_info table.
I want to either:-
a) open the project_details form on the first time to get the users to fill in the form, before the switchboard comes up. But I can't see how to programatically change startup options without having opened the database once already.
b) get the vb function I have written to get the name and number on the switchboard to open the form if there are no records in the table. I have tried using the
DoCmd.OpenForm ("Project_details") in my vb function.
This works if the procedure is run from the vb module but when I try to run it by opening the switchboard (which calls the getProjNumber function via a text box) I get the message "You can't carry out this action at the present time" and the debugger highlights the DoCmd line.
Does anyone have any ideas or do I have to just resign myself to the fact that I'm trying the impossible?!
Here is my function (in the modules section)
Dim rstName As ADODB.Recordset
Set rstName = New ADODB.Recordset
rstName.Open "Project_details", CurrentProject.Connection, adOpenKeyset, adLockOptimistic
If (rstName.BOF = True) Or (rstName.EOF = True) Then
GetProjectName = rstName!Project_name