Solved Docmd.RunSQL INSERT INTO...

Thank you both So much! They work perfectly. Game changing stuff. Thank you for all the help.
 
We are glad to help, good luck with your project.
 
Hey guys, back at it again. I need some help with syntax once more. Got the code below and want to include the Computername listed in the tbl for the record that matches the Currentuser() in the MsgBox after the "you are currently Logged-in " text. Any ideas or is there another way of doing this?

Thank you guys for the help.

Form_Load()
DCount("*", "tblCurrentlyLoggedIn", "empCurrentlyLoggedIn=" & Chr(34) & CurrentUser() & Chr(34)) > 0 And DCount("*", "tblCurrentlyLoggedIn", "empEnviron<>" & Chr(34) & Environ("computername") & Chr(34)) > 0 Then
MsgBox CurrentUser() & _
vbCrLf & " " & _
vbCrLf & " you are currently logged-in " & _
vbCrLf & " " & _
vbCrLf & "Please log-off from the other computer before you continue.", vbExclamation, "Stop, you are logged-in elsewhere."

DoCmd.Quit acQuitSaveAll
 
Perhaps

vbCrLf & " you are currently logged-in to " & Environ("computername") _
 
Perhaps

vbCrLf & " you are currently logged-in to " & Environ("computername") _
That would give the computer name they are using but I want them to be able to know which computer they are already on from the tbl.

Would a Dlookup() work in this case?
 
Oh I'm sorry, I didn't notice the <>. Yes, a DLookup() with the same criteria should work.
 
Oh I'm sorry, I didn't notice the <>. Yes, a DLookup() with the same criteria should work.
Thanks! Got it! See below -

DCount("*", "tblCurrentlyLoggedIn", "empCurrentlyLoggedIn=" & Chr(34) & CurrentUser() & Chr(34)) > 0 And DCount("*", "tblCurrentlyLoggedIn", "empEnviron<>" & Chr(34) & Environ("computername") & Chr(34)) > 0 Then
MsgBox CurrentUser() & _
vbCrLf & " " & _
vbCrLf & " you are logged-in at the computer " & DLookup("empEnviron", "tblCurrentlyLoggedIn", "empCurrentlyLoggedIn=" & Chr(34) & CurrentUser() & Chr(34)) & _
vbCrLf & " " & _
vbCrLf & "Please log-off from the other computer before you continue.", vbExclamation, "Stop, you are logged-in elsewhere."

DoCmd.Quit acQuitSaveAll

Thank you!
 
That would give the computer name they are using but I want them to be able to know which computer they are already on from the tbl.

Would a Dlookup() work in this case?
Yes, that's about what I would do, I think.
 
Yikes! Glad cars (and presumably people) are okay.
 

Users who are viewing this thread

Back
Top Bottom