Prompt on Open

A

aubrey

hello,

i have a field on my form "Reviewed By," which required two initials

is there code for me to be Prompted to enter the initials when i open the
form, so that the initials i entered when i open the form with auto fill all
the records i create

thanks in advance,
 
C

Carl Rapson

Declare a variable at the form module level (before any Subs or Functions)
to hold the initials:

Dim gInitials as String

In the form's Open event, use the InputBox function to prompt for the
initials:

gInitials = InputBox("Enter your initials", "Initials", "XX")

where "XX" is whatever you want for the default initials; if you don't have
this, the user could leave the initials blank. Note that the user could
still leave the initials blank by clicking Cancel on the input box; you may
want to test for this and either re-prompt or close the form (set Cancel to
True). You could also test here and make sure the initials are only 2
characters long, for example.


In the form's Current event, test for a new record and set the initials:

If Me.NewRecord Then
Me.Reviewed_By = gInitials
End If


Carl Rapson
 
A

aubrey

if my initials list include "ar" "iy" and "bs"
how would i define that at the medule level
 
C

Carl Rapson

Not sure what you mean. Are you saying that you want the user to select from
a list of initials, rather than typing the initials? If so, you would have
to do one of two things:

1. Create another form that you would open before this form, containing a
list or combo box with the allowable initials. After the user selects the
initials, the new form opens the existing form, passing the selected
initials in the OpenArgs parameter of the OpenForm call, where you can pick
up the initials in the form's Open event and use them like I showed before.

2. Use the method I described, and test the initials in the form's Open
event. If the initials don't match one of the allowable sets, give an error
message and cancel the form.

Hope this helps,

Carl Rapson
 

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