3 Problems

  • Thread starter Thread starter Paul Scott
  • Start date Start date
P

Paul Scott

I'm using Access 2002.

I have a combo box cboName on a form with a subform. I'm
trying to force my users to select a name. I've tried
IsNull but I get an error.

I'm also trying to SetFocus back to cboName once the
IsNull problem is solved.

Lastly, once my users select a name, I'm wanting to
SetFocus to a RequestedBy field on the subform.

I've tried everything I can think of without any luck.

Any help would be appreciated.

Thanks,

Paul
 
I'm using the following code. I tried the IsNull code in
BeforeUpdate but that didn't work.

Private Sub cboName_AfterUpdate()

Me.RecordsetClone.FindFirst "[MRN] = '" & Me![cboName]_
& "'"
Me.Bookmark = Me.RecordsetClone.Bookmark

If IsNull(cboName) Then
MsgBox "You must select a name.", vbOKOnly
cboName.SetFocus

else

frmRoomCleanSub!RequestedBy.SetFocus

end sub

Again thank for the help,

Paul
-----Original Message-----
Hi Paul,

It would probably be easier to help you if you would post your code - that
generally eliminates a bit of guesswork :-)

Is your code in the form class module of the form being used in the subform?
You probably need to be using the BeforeUpdate event of the form to do this
validation. However, based on the errors you are having I suspect that you
are doing the validation from the main form and your errors are because your
reference to the subform control is not correct.

Post the code along with a description of where the code is located and a
brief description of the fields involved and we'll go from there.

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.

Paul said:
I'm using Access 2002.

I have a combo box cboName on a form with a subform. I'm
trying to force my users to select a name. I've tried
IsNull but I get an error.

I'm also trying to SetFocus back to cboName once the
IsNull problem is solved.

Lastly, once my users select a name, I'm wanting to
SetFocus to a RequestedBy field on the subform.

I've tried everything I can think of without any luck.

Any help would be appreciated.

Thanks,

Paul

.
 
Hi Paul,

Try putting this into the BeforeUpdate event of the form since neither the
BeforeUpdate nor the AfterUpdate events of the combo will fire if the
control is left without a selection (unless there was a selection and the
user cleared it which would then cause the Before/After update events to
occur).

Actually, this code is very confusing to me - in the first part you are
using the value in cboName to find and locate a record in the main form.
Only then are you checking cboName for a null value - is cboName a bound
control or are you using it as a method for locating a record?

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.


Paul said:
I'm using the following code. I tried the IsNull code in
BeforeUpdate but that didn't work.

Private Sub cboName_AfterUpdate()

Me.RecordsetClone.FindFirst "[MRN] = '" & Me![cboName]_
& "'"
Me.Bookmark = Me.RecordsetClone.Bookmark

If IsNull(cboName) Then
MsgBox "You must select a name.", vbOKOnly
cboName.SetFocus

else

frmRoomCleanSub!RequestedBy.SetFocus

end sub

Again thank for the help,

Paul
-----Original Message-----
Hi Paul,

It would probably be easier to help you if you would post your code
- that generally eliminates a bit of guesswork :-)

Is your code in the form class module of the form being used in the
subform? You probably need to be using the BeforeUpdate event of the
form to do this validation. However, based on the errors you are
having I suspect that you are doing the validation from the main
form and your errors are because your reference to the subform
control is not correct.

Post the code along with a description of where the code is located
and a brief description of the fields involved and we'll go from
there.

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.

Paul said:
I'm using Access 2002.

I have a combo box cboName on a form with a subform. I'm
trying to force my users to select a name. I've tried
IsNull but I get an error.

I'm also trying to SetFocus back to cboName once the
IsNull problem is solved.

Lastly, once my users select a name, I'm wanting to
SetFocus to a RequestedBy field on the subform.

I've tried everything I can think of without any luck.

Any help would be appreciated.

Thanks,

Paul

.
 
Back
Top