How do I make a List box Prompt the user to Populated the field

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have created a List box in the form View but how do I make it Prompt the
user to Populated the field ?
 
I have created a List box in the form View but how do I make it Prompt the
user to Populated the field ?

Under what circumstances do you want the prompt? Normally you would simply put
a clearly visible label on the listbox encouraging the user...

A listbox by itself can't issue a prompt, it just sits there waiting for data.
You need some *event* to generate a prompt.

John W. Vinson [MVP]
 
John, Thank you for your help. Please can you show me an example of an Event
t* to generate a prompt.
 
John, Thank you for your help. Please can you show me an example of an Event
t* to generate a prompt.

I'm not sure what you're asking, Arlene. Under what circumstances do you want
the user to be prompted? When they open the form? When they try to leave the
form?

Step back a bit and describe what you're trying to accomplish.

John W. Vinson [MVP]
 
John,

Thank you for reply to my question. I would like the Prompt to be when they
try to leave the from
 
What it is this group, and why is it appearing on my computer?

Yvonne Michele Anderson
(e-mail address removed)
 
John,

Thank you for reply to my question. I would like the Prompt to be when they
try to leave the from

Open the form in design view; view its Properties. On the Events tab find the
BeforeUpdate event. Click the ... icon by that event and choose Code Builder.
Access will give you two lines:

Private Sub Form_BeforeUpdate(Cancel as Integer)

End Sub

You can put whatever code you like in between; you can use MsgBox to issue a
prompt, and you can set Cancel to True to prevent the user from closing the
form. For example:

Private Sub Form_Close(Cancel as Integer)
Dim iAns As Integer
If IsNull(Me!somecontrolname) Then
Cancel = True ' cancel the update of the record
iAns = MsgBox("Yadayada is blank! Fill it or click Cancel to erase:", _
vbOKCancel)
If iAns = vbOK Then
Me!Yadayada.SetFocus ' go to the required control
Else
Me.Undo ' erase the entire form so they can start over
End If
End If
End Sub


John W. Vinson [MVP]
 
John Thank you for replying to me but please could you explain what you mean
by somecontrolname ?

Arlene
 
John Thank you for replying to me but please could you explain what you mean
by somecontrolname ?

The name of the Form Control which you want to ensure is filled in.

John W. Vinson [MVP]
 
John,
Thank you, I have tried the Code but I must be doing something wrong. When
I go to the Form Propeties and go to on close this is what comes up Private
Sub Form_Close() and I enter your code but nothing happens. The Forms Name is
Asset1 and the text box in the form that I am trying to prompt user to
populate is Internal Reference. I have a command box to exit the form called
Command8. Please could you advise where I am going wrong.

Thanks

Arlene
 
John,
Thank you, I have tried the Code but I must be doing something wrong. When
I go to the Form Propeties and go to on close this is what comes up Private
Sub Form_Close() and I enter your code but nothing happens. The Forms Name is
Asset1 and the text box in the form that I am trying to prompt user to
populate is Internal Reference. I have a command box to exit the form called
Command8. Please could you advise where I am going wrong.

Not unless you post the code you have actually put into the event. I can't fix
a problem I can't see!


John W. Vinson [MVP]
 
John,

Sorry but Here is the code. The internal reference is the List box that I am
trying to prompt the user to complete which is in the Form Asset1. I also
have a command button that I have on the form to exit the form called
Command8. Hope you can help.

Private Sub Form_Close()

Dim iAns As Integer
If IsNull(Me!Internal_Reference) Then
Cancel = True ' cancel the update of the record
iAns = MsgBox("Internal_Reference is blank! Fill it or click Cancel to
erase:", _
vbOKCancel)
If iAns = vbOK Then
Me!Internal_Reference.SetFocus ' go to the required control
Else
Me.Undo ' erase the entire form so they can start over
End If
End If

End Sub

Thanks

Arlene
 
John,

Sorry but Here is the code. The internal reference is the List box that I am
trying to prompt the user to complete which is in the Form Asset1. I also
have a command button that I have on the form to exit the form called
Command8. Hope you can help.

Private Sub Form_Close()

Dim iAns As Integer
If IsNull(Me!Internal_Reference) Then
Cancel = True ' cancel the update of the record
iAns = MsgBox("Internal_Reference is blank! Fill it or click Cancel to
erase:", _
vbOKCancel)
If iAns = vbOK Then
Me!Internal_Reference.SetFocus ' go to the required control
Else
Me.Undo ' erase the entire form so they can start over
End If
End If

End Sub

Put all this code in the form's BeforeUpdate event rather than the Close
event.

John W. Vinson [MVP]
 
John,

Sorry but tried the code in before update and the following error comes up.

Run-time error 2465

Microsoft Access can't find the field Internal_Reference referred to in your
expression.

Many Thanks

Arlene
 
John,

Sorry but tried the code in before update and the following error comes up.

Run-time error 2465

Microsoft Access can't find the field Internal_Reference referred to in your
expression.

Many Thanks

Arlene

My code did not contain the term Internal_Reference. Yours apparently does.

Is the field in fact named Internal Reference (with a blank rather than an
underscore)? If so use

[Internal Reference]

with the brackets when you refer to it.

Perhaps you could copy and paste your actual code to a message here, along
with the names of the relevant form controls and table fields.

John W. Vinson [MVP]
 
Back
Top