Full Version: lookup?
UtterAccess Forums > Microsoft® Access > Access Forms
varacn
I have a form - frmSampleLogIn that has a control that captures the username -- environ("username") -- and one that captures the computer name -- environ("computername"). I also have a table of acceptable computer names -- tblValidPC. I would like to change the onopen even on the frmSampleLogIn to check for the computername in tblValidPC. If the computername is NOT there I'd like to have it do the following:
sgbox("You MUST use a specified PC to log samples in!")
docmd exit.application
If the computername is there, it will allow them to continue logging the sample in.
My problem is I'm not sure how to make it look at the tbl to see if it's there. Would it be some sort of lookup?
Thanks for your help! (as always!)
Cindy
Jack Cowley
Here is a rough sample....
CODE
If IsNull(DLookup("ComputerName", "NameOfTableWithComputerNames", "[ComputerName] = '" & VariableWithComputerName & "'" Then
   MsgBox "You must use a specific PC to log samples in!"
   DoCmd.Quit
End if

Look here for details on how to use DLookup()...
hth,
Jack
varacn
Jack!!! Thanks so much! I was hoping you were still around. Don't know if you remember me or not, but you gave me quite a bit of help a year or so ago. I'm in NY... married a "Jack" from Pacifica, Ca. Once again, thanks for your help.
indy
Jack Cowley
Cindy -
REMEMBER YOU! That, in itself, is a miracle, but how many people have I met who married a Jack from Pacifica? I trust all is well in NY and that you and Jack are loving it!!!
Glad I could help and remember that the code I suggested is completely UNTESTED so read the article if the code does not work as suggested...
Very nice to hear from you!!!!
Jack
varacn
Jack -
hings are great here! (except the snow)... but that too will pass... or at least melt! laugh.gif We ended up having a little one... a baby girl, who is now 9 months old. She was born almost 2 months early but is fine and healthy thankfully! I was out of work for about 6 months (most of it I spent in the hospital). We did get back to Pacifica during Thanksgiving and we had beautiful weather and the baby was even good on the plane. His brothers will be in NY at Cooperstown (baseball hall of fame) during July, so I'm not sure when we will get out that way again. Would definitely like to fly into southern ca and work our way up. Anyway, I hope all is well with you!
I've printed out the article already so I can take it with me to work tomorrow. I appreciate your help!
Cindy
Jack Cowley
Cindy -
Congratulations on your baby girl!!! That is wonderful news and I am very happy for all 3 of you!!!
I did you know that it does not snow in Pacifica? No snow. No icy roads. Just clear skies and a few weeks of fog and then nothing but sunshine and warm breezes....well close to that!!!
Thank you for the update and have a good day at work tomorrow!!!
Jack
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.