?
Solved

Access - Form Opening  and performing a Until Loop giving Null Error

Posted on 2012-09-04
5
Medium Priority
?
428 Views
Last Modified: 2012-09-04
I have an Access Form that when the user clicks a control button it opens a second form that has a series of checkboxes.  I am "attempting" to make visible = false a certain number of checkboxes.

The checkboxes are named CkBox1, CkBox2, CkBox3 etc thru CkBox10.  I have an unbound textbox on my form being opened that is populated with a Value from the First form.  Let's say the number is 5.  What I want to happen is CkBox6, 7, 8, 9 & 10 to be made not visible.

This is the Code from the First Form
Private Sub cmdClearChip_Click()
    Dim LResponse As Integer
    
    LResponse = MsgBox("You selected Clear Chip Reporting.  Are you sure this is a WV Lottery Clear Chip reporting?" & vbNewLine & vbNewLine & _
    "PLEASE NOTE: You must select the particular Machine or Machines that are being Clear Chipped.  Check the box of any Machine that the Lottery is performing a Clear Chip!", vbYesNo, "CLEAR CHIP REPORTING")
    'Forms!frm_ClearChipSelectMachines.txtLocNbrMachines = Me.txtNbrMachines
    
    DoCmd.OpenForm "frm_ClearChipSelectMachines", acNormal, , , acFormEdit, acWindowNormal, "frm_ClearChipSelectMachines.txtLocNbrMachines =" & Me.txtNbrMachines
    Call GenerateLVLMachineLines3(LResponse = vbYes)
    Forms!frm_ClearChipSelectMachines.txtNewSeqID = Me.txtNewSeqID
    DoCmd.Close acForm, "frm_LVLREportingTypeSelect", acSaveNo

End Sub

Open in new window


And then this is the Code from the Second form.... I've tried it in the OnLoad and in the OnCurrent
Private Sub Form_Current()
 Dim i As Integer
 
 i = 10
 
 Do Until i = Val(Me.txtLocNbrMachines)
 
    Me.Controls("lblCkBox" & i).Visible = False
    i = i - 1
 Loop
    

End Sub

Open in new window


I get an error saying that it's an invalid use of Null......
0
Comment
Question by:wlwebb
  • 2
  • 2
5 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 38366203
change this line

   DoCmd.OpenForm "frm_ClearChipSelectMachines", acNormal, , , acFormEdit, acWindowNormal, "frm_ClearChipSelectMachines.txtLocNbrMachines =" & Me.txtNbrMachines

with


   DoCmd.OpenForm "frm_ClearChipSelectMachines", acNormal, , , acFormEdit, acWindowNormal, Me.txtNbrMachines
 
  then in the load event of the form  "frm_ClearChipSelectMachines"  place this codes

private sub form_load()

if me.openargs &""<>"" then
   Me.txtLocNbrMachines=me.openargs

Dim i As Integer
 
 i = 10
 
 Do Until i = Val(Me.txtLocNbrMachines)
 
    Me.Controls("lblCkBox" & i).Visible = False
    i = i - 1
 Loop


end if
0
 
LVL 29

Expert Comment

by:IrogSinta
ID: 38366205
If the checkboxes are named CkBox1, CkBox2, CkBox3, etc then this should be
Me.Controls("CkBox" & i).Visible = False
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 total points
ID: 38366212
oops, correction

change this line

   DoCmd.OpenForm "frm_ClearChipSelectMachines", acNormal, , , acFormEdit, acWindowNormal, "frm_ClearChipSelectMachines.txtLocNbrMachines =" & Me.txtNbrMachines

with


   DoCmd.OpenForm "frm_ClearChipSelectMachines", acNormal, , , acFormEdit, acWindowNormal, Me.txtNbrMachines
 
  then in the load event of the form  "frm_ClearChipSelectMachines"  place this codes

private sub form_load()

if me.openargs &""<>"" then
   Me.txtLocNbrMachines=me.openargs

Dim i As Integer
 
 i = 10
 
 Do Until i = Val(Me.txtLocNbrMachines)
 
    Me.Controls("CkBox" & i).Visible = False
    i = i - 1
 Loop


end if
0
 

Author Comment

by:wlwebb
ID: 38366276
Cap1
On your second posting I am getting a compile error
Method or data member not found.......

oops....never mind... mistyped......
0
 

Author Closing Comment

by:wlwebb
ID: 38366285
Thanks Cap 1,  Nice of you to chime in.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
In a use case, a user needs to close an opened report by simply pressing the Escape (Esc) key. This can be done by adding macro code in Report_KeyPress or Report_KeyDown event.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question