Table Search for which form (1 Viewer)

DroneFlyer

New member
Local time
Today, 07:16
Joined
Jun 6, 2022
Messages
2
Hello All;
This is probably a simple solution, for some reason I can not get it to work form me.
I would like when my main navigation form opens up, that it looks in Table 1 for a specific FieldID (D01), if it finds it then continue and open the navigation form, otherwise I want it to open a specific form so that the necessary mandatory data is entered before continuing.

Thank you very much for any assistance
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 19:16
Joined
May 7, 2009
Messages
19,175
use IF and Dcount():

Dim sForm As string
If DCount("1","yourTable","FieldID = 'D01'")<>0 Then
sForm = "yourNavigationFormName"
Else
sForm = "theOtherFormName"
End If
Docmd.OpenForm sForm
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 19:16
Joined
May 7, 2009
Messages
19,175
in a Module you can create a Function that will call the above Code:

Public Function fnOpenForm()
Dim sForm As string
If DCount("1","yourTable","FieldID = 'D01'")<>0 Then
sForm = "yourNavigationFormName"
Else
sForm = "theOtherFormName"
End If
Docmd.OpenForm sForm
End Function


create a Macro (name your macro Autoexec) so when the db opens this macro will run:

RunCode: fnOpenForm()
 

DroneFlyer

New member
Local time
Today, 07:16
Joined
Jun 6, 2022
Messages
2
Thank you very much!!!! The module component work flawlessly.

I appreciate this, and I learned an new technique in coding. Still learning
 

Users who are viewing this thread

Top Bottom