Discussion Locked

Evaluate VBCode for Access 97

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Can someone tell me what is wrong with this code?

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
'If Me!DirCount < 3 Then
If Reports![rptYPPA Order Form]!DirCount < 3 Then
Reports![rptYPPA Order Form]![sbrptYPPADirOrderDetails].Visible
= True
Reports![rptYPPA Order
Form]![sbrptYPPADirOrderDetailsWHITEOUT].Visible = False
Else
Reports![rptYPPA Order Form]![sbrptYPPADirOrderDetails].Visible
= False
Reports![rptYPPA Order
Form]![sbrptYPPADirOrderDetailsWHITEOUT].Visible = True
End If

End Sub

I get no error messages, but it isn't making what I want visible when I
want it. When I step through it, I notice that it goes from the If
statement directly to Else. To me, that means it must be evaluating it
as false. But it's true. The record it is looking at has a DirCount of
2. It is showing up in the supporting query. You can see I commented
out my first reference to the DirCount. I've been experimenting
thinking that I've just got a syntax problem. Please post if you
see anything suspicious or need more information to evaluate it. Thanks
everyone.

3 replies

by sankulpune

Hello,

I guess, DirCount is a text box on the report. Its value is always a string. Hence you need to modify your code either as:
If trim(Reports![rptYPPA Order Form]!DirCount) < "3" Then

or as:

If val(trim(Reports![rptYPPA Order Form]!DirCount)) < 3 Then

I hope this solves your problem.

Your feedback will be highly appreciated.

Please do let me know if you need any additional information.

With best regards,

SanganakSakha.
Simple And Effective Solutions To Small Problems, No QuickFixes.

by learneverything

Sanganak, Thank you for your suggestion. I tinkered with it enough to get it working before I got your answer, which may also have worked. Here is the code that finally got the result I wanted.

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Me.txtDirCount <3 Then
Me.sbfrmYPPADirOrderDetails.Visible = True
Me.sbfrmYPPAlDirOrderDetailsWHITEOUT.Visible = False
Else
Me.sbfrmYPPADirOrderDetails.Visible = False
Me.sbfrmYPPAlDirOrderDetailsWHITEOUT.Visible = True
End If

End Sub

This discussion is closed to new replies.