Choose checkbox by record value then loop rows in report (1 Viewer)

buzzbait9

Registered User.
Local time
Today, 16:39
Joined
May 19, 2015
Messages
18
Hello Ya'll

:banghead:First Part: I have been trying to use to a record value and choose a checkbox. Sat, Unsat, N/A are the 3 boxes. I used the control name and tried Nesting first and then made it simple.

If a.Value = 1 Then
Check68 = True
Check69 = False
Check70 = False
End If
If a.Value = 2 Then
Check68 = False
Check69 = True
Check70 = False
End If
If a.Value = 3 Then
Check68 = False
Check69 = False
Check70 = True

When the report comes up, the check boxes are all empty.

:banghead:Second Part: Even if the checkboxes were full, I'm having trouble looping through each page of the report. Each row of the query ends a page and the next page starts on a new row. The new record has to default the checkboxes back to 0 so the values can change for the next page. Of course like the above, I tried the easiest way but I wasn't successful.

Dim rst As Recordset, i As Integer

Set rst = Me.RecordsetClone
i = 0
rst.MoveFirst
Do While Not rst.EOF
i = i + 1
rst.Edit
rst![SelectServComplete] = Null
rst![a] = Null
rst! = Null
rst![c] = Null
rst![d] = Null
rst![e] = Null
rst![f] = Null
rst![g] = Null
rst![h] = Null
rst! = Null
rst![j] = Null
rst![k] = Null
rst![l] = Null
rst![m] = Null
rst.Update
rst.MoveNext
Loop
rst.Close
Set rst = Nothing

Is there hope for me?:eek:

Thank you
 

June7

AWF VIP
Local time
Today, 13:39
Joined
Mar 9, 2014
Messages
5,465
Can't use VBA to directly set values of controls on report. Use expression in ControlSource.

Check68:
= [a]=1

Check69:
= [a]=2

Check70:
= [a]=3

Otherwise, ControlSource can call a VBA custom function that returns a value.
=MyFunction(argument parameters if required by function)
 
Last edited:

buzzbait9

Registered User.
Local time
Today, 16:39
Joined
May 19, 2015
Messages
18
Wow, Sorry, Thank you for responding. That went way over my head. The reset that I was trying to do is when the loop gets to the end of the row, it reads the next row values and then populates the check box values as it reads the new rows of values. I wasn't sure that when finished, the new values would replace the previous row values to populate the new boxes.:rolleyes:

I'm going to have to rethink the whole process.

Thanks again
 

June7

AWF VIP
Local time
Today, 13:39
Joined
Mar 9, 2014
Messages
5,465
Did you try the suggestion?

The concept is if [a] = 1 then the checkbox will show True otherwise it is False. Since this is a data-dependent expression, each record will show result specific to its data.

This assumes [a] is a field in the report RecordSource. Now this brings up the question of how fields through [m] factor into this. You don't show any code for that. Better describe the logic you are trying to code.
 

Users who are viewing this thread

Top Bottom