won't let you into form if textbox entry not found in table

P

p-rat

From my switchboard I have a selection "Enter Field Ticket
Information". When clicked I would like a dialog box or some form pop-
up and ask "What location?". The end-user would then type in their
location.

There is a table that I have called UserLocation. In this table I have
a field User and a field Location. The User field is their logon. It's
the GetUserName script. If the location the end-user types in the
dialog box or form = location in table and the user = user for that
location then I want the data entry form to pop-up for the end-user to
enter in their Field Ticket information. If the location they type in
doesn't match or the UserName doesn't equal that of the location then
I want a textbox to pop-up saying "sorry you are not authorized to
enter information for this location".

Would anyone know how I can make this work? Any help would be
appreciated. Thanks.
 
P

p-rat

Thanks for your help. I did what you said and it works great. I
appreciate it. One other thing I would like to do and have done on
other forms other than 'Modal' is to have the value of , in our
example, "Location" on the modal form "frmIdentify" to become the
default value on the data entry form (along with a textbox on the
modal form for date). this is a request from the end users to speed up
their entry (they don't have to keep entering in location if they have
a stack of tickets to enter for the same location). let me know if
this can be done. thanks.
 
P

p-rat

How about another textbox on the modal form ("frmIdentify") for the
date. How can I have that as a default value on the main form? Thanks.
Your changes work without a problem. Thanks again for your help.


hi again
since we're already using the tag property, you can use it to save the
location and add it on every new record:
change the code to on the main form to:

if me.tag="x" then cancel=1 (there is no location, so the user failed)

and on frmIdentify to:

If DCount("User", "UserLocation", "User='" & GetUserName() & "' And
Location='" & txtLocation & "'") = 0 Then
   MsgBox "sorry you are not authorized to enter information for this
location"
Else
   Forms!frmDataEntry.Tag = txtLocation
End If
DoCmd.Close acForm, "frmIdentify"

now that you have the user's location in the tag property, use the
BeforeInsert event of the form to update the location to the tag property's
value:

Location=me.tag

this will insert the location every time the user adds a new record,
make sure the first control in the tab order is the other control (not the
location, cause that one is inserted by code) or the user wont understand
what is going on

good luck again
Erez





p-rat said:
Thanks for your help. I did what you said and it works great. I
appreciate it. One other thing I would like to do and have done on
other forms other than 'Modal' is to have the value of , in our
example, "Location" on the modal form "frmIdentify" to become the
default value on the data entry form (along with a textbox on the
modal form for date). this is a request from the end users to speed up
their entry (they don't have to keep entering in location if they have
a stack of tickets to enter for the same location). let me know if
this can be done. thanks.
hi
set the switchboard option to open the data entry form (the final destination)
[quoted text clipped - 62 lines]
- Show quoted text -

--
May all beings be happy.

Message posted via AccessMonster.comhttp://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200903/1- Hide quoted text -

- Show quoted text -
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top