String to shrink textboxes

ErickMJ

Registered User.
Local time
Today, 05:25
Joined
Aug 6, 2012
Messages
18
I have a report with a form that supplies values for it to filter the fields in the report on, but also checkboxes to make the fields "disappear" if the user doesn't want them in the report. Problem is I can't get the mechanism to make them disappear work right. Here's the code I made:

Option Compare Database
Private Sub Report_Load()
Dim i As Integer, j As Integer, width As Integer
j = 23
For i = 1 To j
If "0 = Forms.CustomReportFilter.['Checkbox' & i]" Then
width = "0"
End If
Next i
Me.Controls("text" & i).width = width

End Sub

I'm getting an error 13, data type mismatch in the "0=Forms...." section. Does anyone know a better way to accomplish this or make this code work?
 
Try

If Forms.CustomReportFilter("Checkbox" & i) = 0 Then
 
Thanks, that syntax removes all errors and allows the report to run, however it's not making the textboxes disappear as I had hoped. It appeared to do so, but apparently that was something wrong with my filter, and with that fixed this code is barely effective.

Option Compare Database

Private Sub Report_Open(Cancel As Integer)
Dim i As Integer, j As Integer, width As Integer
j = 22
For i = 1 To j
If Forms.CustomReportFilter("Checkbox" & i) = 0 Then
width = "0"
End If
Next i
Me.Controls("textbox" & i).width = width
Me.Controls("Labels" & i).width = width
End Sub

Any ideas?
 
instead of using Whatever.Width = Something

why not use Whatever.Visible = true/false ?
 
I was considering that, but the problem is I then have a report with awkward holes between the fields. The invisible ones still occupy the space. If you know how I might fix that, invisible would probably work better. Thanks!
 
Ah, I got it. I was playing around with the invisible code, which essentially required me to get rid of the "width" variable, and in the end that solved my width dilemna. Working code looks like this for those wondering:

Option Compare Database

Private Sub Report_Open(Cancel As Integer)
Dim i As Integer, j As Integer
j = 22
For i = 1 To j
If Forms.CustomReportFilter("Check" & i) = 0 Then
Me.Controls("textbox" & i).width = 0
End If
If Forms.CustomReportFilter("Check" & i) = 0 Then
Me.Controls("Labels" & i).width = 0
End If
Next i
End Sub

Thanks for the help!
 
I was considering that, but the problem is I then have a report with awkward holes between the fields. The invisible ones still occupy the space. If you know how I might fix that, invisible would probably work better. Thanks!
fair enough :P a little difficult to help out on things like this one without physically seeing how the form is laid out. ;)

anyway, glad you got it solved!
 

Users who are viewing this thread

Back
Top Bottom