Hello,

I have made a database system, when the database opens a login form appears and the username and password need to be typed into the text boxes. if admin is the username then the main switchboard. but if you log in as driver then a report opens. the trouble is when the report closes (report is called "rptdrivers deilveries (drivers report)" i want it to open the login form again, which i can do. but on my main switchboard i also have the same report and i dont want this to open the login form when closed. how do i make the report open the login form when closed, but only when it has been opened when logged in as driver

Here is the code for the login form:

Private Sub Command8_Click()
If Text1.value = "admin" And Text3.value = "password" Then
DoCmd.Close acForm, "Login"
DoCmd.OpenForm "Switchboard"
Else
If Text1.value = "driver" And Text3.value = "password" Then
DoCmd.Close acForm, "Login"
DoCmd.OpenReport "rptDriverDeliveries (Drivers report)", acViewPreview
Else
MsgBox ("Incorrect Username and Password")
End If
End If
End Sub

Private Sub Command9_Click()
DoCmd.OpenForm "Quit?"
End Sub

Private Sub Form_Unload(Cancel As Integer)
If Text1.value = "admin" And Text3.value = "password" Then
Cancel = False
Else
If Text1.value = "driver" And Text3.value = "password" Then
Cancel = False
Else
Cancel = True
End If
End If
End Sub

and here is the code for the report:

Private Sub Report_Close()
If Text1.value = "driver" And Text3.value = "password" Then
DoCmd.OpenForm "Login"
Else
End If
End Sub

btw if you would like to see the system to get a better idea of how it works to answer my question can you please email me - edowen14@hotmail.co.uk

THANK YOU

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.