Nasty Error 94 msg

G

Guest

The code below causes the nasty "Error 94(Invalid Use of Null in procedure
Form_Current of VBA Doc Form_frmVisitNewEdit. It happens when changing
patients, or when going to a patient that has now visits.

I looked at previous posts and I made sure that there is no conflict with
the AllowEdits properties of the forms. If I comment out the code below I
don't get the error msg, but then I also don't get the use of the code I'm
using to select an appropriate pg.

As always, your help is greatly appreciated. Thanks, Rob
*******************************************************

Private Sub Form_Current()
On Error GoTo Form_Current_Error

Me.Refresh

Dim T_Visit As String
T_Visit = Me.fldVisitType

'first hide all controls
Me.pgAblations.Visible = False
Me.pgCardioversions.Visible = False
Me.pgClinicVisits.Visible = False
Me.pgDevices.Visible = False
Me.pgTilts.Visible = False
Me.pgTelephone.Visible = False

'now show one control
Select Case T_Visit

Case "Ablation"
Me.pgAblations.Visible = True

Case "Device"
Me.pgDevices.Visible = True

Case "Clinic"
Me.pgClinicVisits.Visible = True

Case "Cardioversion"
Me.pgCardioversions.Visible = True

Case "Telephone"
Me.pgTelephone.Visible = True

Case "Tilt Table"
Me.pgTilts.Visible = True

End Select

Me.lstVisit.SetFocus
On Error GoTo 0
Exit Sub

Form_Current_Error:

MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure
Form_Current of VBA Document Form_frmVisitNewEdit"

End Sub
 
R

ruralguy via AccessMonster.com

Hi Rob,
You don't have a Case Else and you are not checking for a Null in the Me.
fldVisitType control. As you discovered, Access does not like you trying to
put a Null into a String variable.
 
G

Guest

Any suggesitons on how to fix this? Thanks, Rob

ruralguy via AccessMonster.com said:
Hi Rob,
You don't have a Case Else and you are not checking for a Null in the Me.
fldVisitType control. As you discovered, Access does not like you trying to
put a Null into a String variable.


--
HTH - RuralGuy (RG for short) acXP WinXP Pro
Please post back to this forum so all may benefit.

Message posted via AccessMonster.com
 
R

ruralguy via AccessMonster.com

T_Visit = Nz(Me.fldVisitType)
will subsitute "" if Null and none of your Case statements will match and the
error will go away.
Any suggesitons on how to fix this? Thanks, Rob
Hi Rob,
You don't have a Case Else and you are not checking for a Null in the Me.
[quoted text clipped - 62 lines]
 
G

Guest

I know I'm getting anoying but I'm not sure were to insert T_Visit =
Nz(Me.fldVisitType) in my code. Could you please help. Thanks for your
patience and help. As you can tell, I'm very much the rookie. Thanks, Rob


ruralguy via AccessMonster.com said:
T_Visit = Nz(Me.fldVisitType)
will subsitute "" if Null and none of your Case statements will match and the
error will go away.
Any suggesitons on how to fix this? Thanks, Rob
Hi Rob,
You don't have a Case Else and you are not checking for a Null in the Me.
[quoted text clipped - 62 lines]

--
HTH - RuralGuy (RG for short) acXP WinXP Pro
Please post back to this forum so all may benefit.

Message posted via AccessMonster.com
 
D

Douglas J. Steele

Ruralguy's suggesting that Instead of

T_Visit = Me.fldVisitType

you put

T_Visit = Nz(Me.fldVisitType, "")

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


RobUCSD said:
I know I'm getting anoying but I'm not sure were to insert T_Visit =
Nz(Me.fldVisitType) in my code. Could you please help. Thanks for your
patience and help. As you can tell, I'm very much the rookie. Thanks, Rob


ruralguy via AccessMonster.com said:
T_Visit = Nz(Me.fldVisitType)
will subsitute "" if Null and none of your Case statements will match and
the
error will go away.
Any suggesitons on how to fix this? Thanks, Rob

Hi Rob,
You don't have a Case Else and you are not checking for a Null in the
Me.
[quoted text clipped - 62 lines]

End Sub

--
HTH - RuralGuy (RG for short) acXP WinXP Pro
Please post back to this forum so all may benefit.

Message posted via AccessMonster.com
 
R

ruralguy via AccessMonster.com

Hi Rob,
Doug is correct. It is the line after the Dim statement at the beginning of
the code you posted. The default replacement for a Null is a Zero Length
String (ZLS) so:
Nz(Me.fldVisitType, "")
and
Nz(Me.fldVisitType)
are basically the same thing, but Doug's line is more complete.
Ruralguy's suggesting that Instead of

T_Visit = Me.fldVisitType

you put

T_Visit = Nz(Me.fldVisitType, "")
I know I'm getting anoying but I'm not sure were to insert T_Visit =
Nz(Me.fldVisitType) in my code. Could you please help. Thanks for your
[quoted text clipped - 13 lines]
 
G

Guest

I'm still getting Error 94, and also "Can't set value to Null when checkbox
proerty =false." I don't know the proper method for checking for nulls. I
inserted RG's suggestion in a Case Else clause. I must not be the correct
place. Please Help.

Thanks, Rob

Private Sub Form_Current()
On Error GoTo Form_Current_Error

Me.Refresh

Dim T_Visit As String
T_Visit = Me.fldVisitType

'first hide all controls
Me.pgAblations.Visible = False
Me.pgCardioversions.Visible = False
Me.pgClinicVisits.Visible = False
Me.pgDevices.Visible = False
Me.pgTilts.Visible = False
Me.pgTelephone.Visible = False

'now show one control
Select Case T_Visit

Case "Ablation"
Me.pgAblations.Visible = True

Case "Device"
Me.pgDevices.Visible = True

Case "Clinic"
Me.pgClinicVisits.Visible = True

Case "Cardioversion"
Me.pgCardioversions.Visible = True

Case "Telephone"
Me.pgTelephone.Visible = True

Case "Tilt Table"
Me.pgTilts.Visible = True

Case Else
T_Visit = Nz(Me.fldVisitType, "")

End Select

Me.lstVisit.SetFocus
On Error GoTo 0
Exit Sub

Form_Current_Error:

MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure
Form_Current of VBA Document Form_frmVisitNewEdit"

End Sub

Douglas J. Steele said:
Ruralguy's suggesting that Instead of

T_Visit = Me.fldVisitType

you put

T_Visit = Nz(Me.fldVisitType, "")

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


RobUCSD said:
I know I'm getting anoying but I'm not sure were to insert T_Visit =
Nz(Me.fldVisitType) in my code. Could you please help. Thanks for your
patience and help. As you can tell, I'm very much the rookie. Thanks, Rob


ruralguy via AccessMonster.com said:
T_Visit = Nz(Me.fldVisitType)
will subsitute "" if Null and none of your Case statements will match and
the
error will go away.

RobUCSD wrote:
Any suggesitons on how to fix this? Thanks, Rob

Hi Rob,
You don't have a Case Else and you are not checking for a Null in the
Me.
[quoted text clipped - 62 lines]

End Sub

--
HTH - RuralGuy (RG for short) acXP WinXP Pro
Please post back to this forum so all may benefit.

Message posted via AccessMonster.com
 
R

ruralguy via AccessMonster.com

Give this code a try Rob:

Private Sub Form_Current()
On Error GoTo Form_Current_Error

Me.Refresh

Dim T_Visit As String
T_Visit = Nz(Me.fldVisitType, "")


'first hide all controls
Me.pgAblations.Visible = False
Me.pgCardioversions.Visible = False
Me.pgClinicVisits.Visible = False
Me.pgDevices.Visible = False
Me.pgTilts.Visible = False
Me.pgTelephone.Visible = False

'now show one control
Select Case T_Visit

Case "Ablation"
Me.pgAblations.Visible = True

Case "Device"
Me.pgDevices.Visible = True

Case "Clinic"
Me.pgClinicVisits.Visible = True

Case "Cardioversion"
Me.pgCardioversions.Visible = True

Case "Telephone"
Me.pgTelephone.Visible = True

Case "Tilt Table"
Me.pgTilts.Visible = True

End Select

Me.lstVisit.SetFocus
On Error GoTo 0
Exit Sub

Form_Current_Error:

MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure
Form_Current of VBA Document Form_frmVisitNewEdit"

End Sub

I'm still getting Error 94, and also "Can't set value to Null when checkbox
proerty =false." I don't know the proper method for checking for nulls. I
inserted RG's suggestion in a Case Else clause. I must not be the correct
place. Please Help.

Thanks, Rob

Private Sub Form_Current()
On Error GoTo Form_Current_Error

Me.Refresh

Dim T_Visit As String
T_Visit = Me.fldVisitType

'first hide all controls
Me.pgAblations.Visible = False
Me.pgCardioversions.Visible = False
Me.pgClinicVisits.Visible = False
Me.pgDevices.Visible = False
Me.pgTilts.Visible = False
Me.pgTelephone.Visible = False

'now show one control
Select Case T_Visit

Case "Ablation"
Me.pgAblations.Visible = True

Case "Device"
Me.pgDevices.Visible = True

Case "Clinic"
Me.pgClinicVisits.Visible = True

Case "Cardioversion"
Me.pgCardioversions.Visible = True

Case "Telephone"
Me.pgTelephone.Visible = True

Case "Tilt Table"
Me.pgTilts.Visible = True

Case Else
T_Visit = Nz(Me.fldVisitType, "")

End Select

Me.lstVisit.SetFocus
On Error GoTo 0
Exit Sub

Form_Current_Error:

MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure
Form_Current of VBA Document Form_frmVisitNewEdit"

End Sub
Ruralguy's suggesting that Instead of
[quoted text clipped - 21 lines]
 
G

Guest

RG, thanks very much for your time and patience. It's working now. Thanks, Rob

ruralguy via AccessMonster.com said:
Give this code a try Rob:

Private Sub Form_Current()
On Error GoTo Form_Current_Error

Me.Refresh

Dim T_Visit As String
T_Visit = Nz(Me.fldVisitType, "")


'first hide all controls
Me.pgAblations.Visible = False
Me.pgCardioversions.Visible = False
Me.pgClinicVisits.Visible = False
Me.pgDevices.Visible = False
Me.pgTilts.Visible = False
Me.pgTelephone.Visible = False

'now show one control
Select Case T_Visit

Case "Ablation"
Me.pgAblations.Visible = True

Case "Device"
Me.pgDevices.Visible = True

Case "Clinic"
Me.pgClinicVisits.Visible = True

Case "Cardioversion"
Me.pgCardioversions.Visible = True

Case "Telephone"
Me.pgTelephone.Visible = True

Case "Tilt Table"
Me.pgTilts.Visible = True

End Select

Me.lstVisit.SetFocus
On Error GoTo 0
Exit Sub

Form_Current_Error:

MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure
Form_Current of VBA Document Form_frmVisitNewEdit"

End Sub

I'm still getting Error 94, and also "Can't set value to Null when checkbox
proerty =false." I don't know the proper method for checking for nulls. I
inserted RG's suggestion in a Case Else clause. I must not be the correct
place. Please Help.

Thanks, Rob

Private Sub Form_Current()
On Error GoTo Form_Current_Error

Me.Refresh

Dim T_Visit As String
T_Visit = Me.fldVisitType

'first hide all controls
Me.pgAblations.Visible = False
Me.pgCardioversions.Visible = False
Me.pgClinicVisits.Visible = False
Me.pgDevices.Visible = False
Me.pgTilts.Visible = False
Me.pgTelephone.Visible = False

'now show one control
Select Case T_Visit

Case "Ablation"
Me.pgAblations.Visible = True

Case "Device"
Me.pgDevices.Visible = True

Case "Clinic"
Me.pgClinicVisits.Visible = True

Case "Cardioversion"
Me.pgCardioversions.Visible = True

Case "Telephone"
Me.pgTelephone.Visible = True

Case "Tilt Table"
Me.pgTilts.Visible = True

Case Else
T_Visit = Nz(Me.fldVisitType, "")

End Select

Me.lstVisit.SetFocus
On Error GoTo 0
Exit Sub

Form_Current_Error:

MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure
Form_Current of VBA Document Form_frmVisitNewEdit"

End Sub
Ruralguy's suggesting that Instead of
[quoted text clipped - 21 lines]

--
HTH - RuralGuy (RG for short) acXP WinXP Pro
Please post back to this forum so all may benefit.

Message posted via AccessMonster.com
 
R

ruralguy via AccessMonster.com

Glad Doug and I could help. Thanks for posting back with your success.
RG, thanks very much for your time and patience. It's working now. Thanks, Rob
Give this code a try Rob:
[quoted text clipped - 114 lines]
 

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