General discussion

Locked

Evaluate VBCode for Access 97

By learneverything ·
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.

This conversation is currently closed to new comments.

3 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Evaluate VBCode for Access 97

by SanKulPune In reply to Evaluate VBCode for Acces ...

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.

Collapse -

Evaluate VBCode for Access 97

by learneverything In reply to Evaluate VBCode for Acces ...

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 Then
Me.sbfrmYPPADirOrderDetails.Visible = True
Me.sbfrmYPPAlDirOrderDetailsWHITEOUT.Visible = False
Else
Me.sbfrmYPPADirOrderDetails.Visible = False
Me.sbfrmYPPAlDirOrderDetailsWHITEOUT.Visible = True
End If

End Sub

Collapse -

Evaluate VBCode for Access 97

by learneverything In reply to Evaluate VBCode for Acces ...

This question was closed by the author

Back to Software Forum
3 total posts (Page 1 of 1)  

Related Forums