Solved Docmd.RunSQL INSERT INTO... (2 Viewers)

evictme

Registered User.
Local time
Today, 03:13
Joined
May 18, 2011
Messages
168
Thank you both So much! They work perfectly. Game changing stuff. Thank you for all the help.
 

Isaac

Lifelong Learner
Local time
Today, 01:13
Joined
Mar 14, 2017
Messages
8,738
We are glad to help, good luck with your project.
 

evictme

Registered User.
Local time
Today, 03:13
Joined
May 18, 2011
Messages
168
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
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 01:13
Joined
Aug 30, 2003
Messages
36,118
Perhaps

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

evictme

Registered User.
Local time
Today, 03:13
Joined
May 18, 2011
Messages
168
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?
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 01:13
Joined
Aug 30, 2003
Messages
36,118
Oh I'm sorry, I didn't notice the <>. Yes, a DLookup() with the same criteria should work.
 

evictme

Registered User.
Local time
Today, 03:13
Joined
May 18, 2011
Messages
168
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!
 

Isaac

Lifelong Learner
Local time
Today, 01:13
Joined
Mar 14, 2017
Messages
8,738
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.
 

Isaac

Lifelong Learner
Local time
Today, 01:13
Joined
Mar 14, 2017
Messages
8,738
Get distracted while posting? ;)
Very much so, it seems! Sorry. The garage door guy came ... ours collapsed last night. Thankfully, not on the cars.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 01:13
Joined
Aug 30, 2003
Messages
36,118
Yikes! Glad cars (and presumably people) are okay.
 

Users who are viewing this thread

Top Bottom