changing prompt wording

C

Colin Ward

I have a menu system in my app. I have buttons for
adding, browsing and editing various things. when the
user finishes one of these actions, and clicks the exit
button that I created, a prompt comes up asking them if
they would like to ADD anything else. It does this
regardless of whether they were in add, browse or edit
mode, is there a way to figure out what mode the form was
opened in and change the prompt to reflect that?

Thanks

Colin
 
F

Fredg

Colin,
Place your code in the Form's Unload event.
Make the MsgBox a function to allow the event to be cancelled
and returned to the form for additional entries if the user
wants to add or edit more data.

Here is how to read the current state:
Note: the form may have more than one of these properties
active, so adjust the code as needed.

Dim strState as String
Dim intResponse as Integer

If Me.DataEntry = True Then
strState = "Exit the Data entry form?"
Else
If Me.AllowEdits = True Then
strState = "Edit any more records?"
ElseIf Me.AllowAdditions = True Then
strState = "You can still add more records if you want"
End If
End If
intResponse = MsgBox(strState, vbExclamation + vbYesNo)
If intResponse = vbNo then
Cancel = True
End If

See the properties on the Data tab of the Form's property sheet.
 
G

Graham Mandeno

Hi Colin

If you open a form in data entry mode (acFormAdd), then the form's DataEntry
property will be set to True. Similarly, in read-only mode
(acFormReadOnly), the AllowEdits property will be set to False. Is this
what you mean?

If not, then you could set the value of a variable, depending on whether
Add, Browse, or Edit was clicked. Then inspect this variable on exit and
display the appropriate message.

--
Good Luck!
Graham Mandeno [Access MVP]
Auckland, New Zealand

Return mail address is invalid in a vain attempt to reduce spam.
Feedback is welcome at: (e-mail address removed)
Please post new questions or followups to newsgroup.
 

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