• ** There has been a recent site upgrade. Please clear your browser cache to avoid issues. **
  • New forum feature - post voting and best solution

    Check out this thread for the details: https://www.access-programmers.co.uk/forums/threads/new-forum-feature-post-voting-and-best-answer.314134/

    This new feature looks great to me! :)

  • We now have 3 forum themes

    Go for the default (light) theme, Shades of Grey or Shades of Blue. I just added the Blue one.

    The thread about it is here: https://www.access-programmers.co.uk/forums/threads/new-forum-theme-shades-of-blue.314136/

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

evictme

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

Isaac

Lifelong Learner
Local time
Today, 03:35
Joined
Mar 14, 2017
Messages
2,372
We are glad to help, good luck with your project.
 

evictme

Registered User.
Local time
Today, 05:35
Joined
May 18, 2011
Messages
120
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, 03:35
Joined
Aug 30, 2003
Messages
34,601
Perhaps

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

evictme

Registered User.
Local time
Today, 05:35
Joined
May 18, 2011
Messages
120
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, 03:35
Joined
Aug 30, 2003
Messages
34,601
Oh I'm sorry, I didn't notice the <>. Yes, a DLookup() with the same criteria should work.
 

evictme

Registered User.
Local time
Today, 05:35
Joined
May 18, 2011
Messages
120
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, 03:35
Joined
Mar 14, 2017
Messages
2,372
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, 03:35
Joined
Mar 14, 2017
Messages
2,372
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, 03:35
Joined
Aug 30, 2003
Messages
34,601
Yikes! Glad cars (and presumably people) are okay.
 

Users who are viewing this thread

Top Bottom