A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Checkbox values at run time



 
 
Thread Tools Display Modes
  #1  
Old April 29th, 2008, 07:33 PM posted to microsoft.public.access.forms
Rockn
external usenet poster
 
Posts: 48
Default Checkbox values at run time

I am trying to set up a form that will dynamically assign values to
checkboxes that are part of an option group based on the cintents of a
table.

I have set up a test form with six checkboxes and made them all hidden. I
would now like to loop through a recordset and for each record assign a
value to these controls attributes.

visible = true
option.value = PK of the record
label.value = Name of field in record
and loop to the next.

I would think I would also have to count the number of checkboxes to set the
upper bound for the loop and make sure it is not less than the number of
records in the recordset I am looking at.

Any help would be appreciated.


  #2  
Old April 30th, 2008, 08:22 AM posted to microsoft.public.access.forms
Charles Wang [MSFT]
external usenet poster
 
Posts: 68
Default Checkbox values at run time

Hi Rockn,
I am not sure if I totally understand your meaning. You had six checkboxes
and you said that you need to make sure that the number of checkboxes is
not less than the number of records in the recordset you are looking at. So
I understand that there are must be less than or equal to six records in
your recordset, right?

If this is true, why do not you count the number of the records in the
recordset and then loop through your recordset and dynamically set your
checkboxes properties accordingly?

Please feel free to let me know if I have any misunderstanding or if you
have any other questions or concerns. Have a nice day!


Best regards,
Charles Wang
Microsoft Online Community Support
================================================== =========
Delighting our customers is our #1 priority. We welcome your
comments and suggestions about how we can improve the
support we provide to you. Please feel free to let my manager
know what you think of the level of service provided. You can
send feedback directly to my manager at: .
================================================== =========
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for
non-urgent issues where an initial response from the community
or a Microsoft Support Engineer within 1 business day is acceptable.
Please note that each follow up response may take approximately
2 business days as the support professional working with you may
need further investigation to reach the most efficient resolution.
The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by
contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
================================================== ==========
This posting is provided "AS IS" with no warranties, and confers no rights.
================================================== =======

  #3  
Old April 30th, 2008, 03:43 PM posted to microsoft.public.access.forms
Rockn
external usenet poster
 
Posts: 48
Default Checkbox values at run time

I am wanting to make sure that the number of checkboxes is not less than the
number of records in the table. If there were to be less checkboxes than the
number of records in the table the correct number of checkboxes would not be
revealed at run time if there was more records.

I am not sure how to loop through the recordset, but I am assuming that I
can use a Do While the count of records does not exceed the number of
controls it will set their properties. How would I dynamically reference the
checkbox controls because they are already named and the values for each are
already set from design view or can you change any control attribute at run
time?

""Charles Wang [MSFT]"" wrote in message
...
Hi Rockn,
I am not sure if I totally understand your meaning. You had six checkboxes
and you said that you need to make sure that the number of checkboxes is
not less than the number of records in the recordset you are looking at.
So
I understand that there are must be less than or equal to six records in
your recordset, right?

If this is true, why do not you count the number of the records in the
recordset and then loop through your recordset and dynamically set your
checkboxes properties accordingly?

Please feel free to let me know if I have any misunderstanding or if you
have any other questions or concerns. Have a nice day!


Best regards,
Charles Wang
Microsoft Online Community Support
================================================== =========
Delighting our customers is our #1 priority. We welcome your
comments and suggestions about how we can improve the
support we provide to you. Please feel free to let my manager
know what you think of the level of service provided. You can
send feedback directly to my manager at: .
================================================== =========
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for
non-urgent issues where an initial response from the community
or a Microsoft Support Engineer within 1 business day is acceptable.
Please note that each follow up response may take approximately
2 business days as the support professional working with you may
need further investigation to reach the most efficient resolution.
The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by
contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
================================================== ==========
This posting is provided "AS IS" with no warranties, and confers no
rights.
================================================== =======



  #4  
Old May 1st, 2008, 08:58 AM posted to microsoft.public.access.forms
Charles Wang [MSFT]
external usenet poster
 
Posts: 68
Default Checkbox values at run time

Hi Rockn,
You can save your checkboxes names and labels names into two arrays. Then
you can dynamic set the attributes according to the record loop and the
array index.
For example:
===================================
Public chkList As Variant
Public lblList As Variant


Private Sub cmdLoad_Click()
Dim dbsTest As DAO.Database
Dim rsTasks As DAO.Recordset
Dim strSQL As String
Dim strChkName As String
Dim strLblName As String
Dim intI As Integer

chkList = Array("chk0", "chk1", "chk2", "chk3", "chk4", "chk5")
lblList = Array("lbl0", "lbl1", "lbl2", "lbl3", "lbl4", "lbl5")

On Error GoTo ErrorHandler

Set dbsTest = CurrentDb
strSQL = "SELECT * FROM Tasks"
intI = 0
Set rsTasks = dbsTest.OpenRecordset(strSQL, dbOpenDynaset)
With rsTasks
Do Until .EOF
If intI 6 Then
strChkName = chkList(intI)
strLblName = lblList(intI)

Me.Controls(strChkName).Visible = True
Me.Controls(strLblName).Visible = True
Me.Controls(strChkName).Value = .Fields("ID").Value
Me.Controls(strLblName).Caption = .Fields("TASK_NAME").Value
intI = intI + 1
End If
.MoveNext
Loop
End With
rsTasks.Close
Set rsTasks = Nothing

Exit Sub
ErrorHandler:
MsgBox "Error #: " & Err.Number & vbCrLf & vbCrLf & Err.Description

End Sub
===========================================

Hope this helps. If you have any other questions or concerns, please feel
free to let me know. Have a nice day!

Best regards,
Charles Wang
Microsoft Online Community Support
================================================== =========
Delighting our customers is our #1 priority. We welcome your
comments and suggestions about how we can improve the
support we provide to you. Please feel free to let my manager
know what you think of the level of service provided. You can
send feedback directly to my manager at: .
================================================== =========
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for
non-urgent issues where an initial response from the community
or a Microsoft Support Engineer within 1 business day is acceptable.
Please note that each follow up response may take approximately
2 business days as the support professional working with you may
need further investigation to reach the most efficient resolution.
The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by
contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
================================================== ==========
This posting is provided "AS IS" with no warranties, and confers no rights.
================================================== =======


  #5  
Old May 1st, 2008, 09:18 PM posted to microsoft.public.access.forms
Rockn
external usenet poster
 
Posts: 48
Default Checkbox values at run time

That was awesome!! Thanks for the info, it is greatly appreciated.


""Charles Wang [MSFT]"" wrote in message
...
Hi Rockn,
You can save your checkboxes names and labels names into two arrays. Then
you can dynamic set the attributes according to the record loop and the
array index.
For example:
===================================
Public chkList As Variant
Public lblList As Variant


Private Sub cmdLoad_Click()
Dim dbsTest As DAO.Database
Dim rsTasks As DAO.Recordset
Dim strSQL As String
Dim strChkName As String
Dim strLblName As String
Dim intI As Integer

chkList = Array("chk0", "chk1", "chk2", "chk3", "chk4", "chk5")
lblList = Array("lbl0", "lbl1", "lbl2", "lbl3", "lbl4", "lbl5")

On Error GoTo ErrorHandler

Set dbsTest = CurrentDb
strSQL = "SELECT * FROM Tasks"
intI = 0
Set rsTasks = dbsTest.OpenRecordset(strSQL, dbOpenDynaset)
With rsTasks
Do Until .EOF
If intI 6 Then
strChkName = chkList(intI)
strLblName = lblList(intI)

Me.Controls(strChkName).Visible = True
Me.Controls(strLblName).Visible = True
Me.Controls(strChkName).Value = .Fields("ID").Value
Me.Controls(strLblName).Caption = .Fields("TASK_NAME").Value
intI = intI + 1
End If
.MoveNext
Loop
End With
rsTasks.Close
Set rsTasks = Nothing

Exit Sub
ErrorHandler:
MsgBox "Error #: " & Err.Number & vbCrLf & vbCrLf & Err.Description

End Sub
===========================================

Hope this helps. If you have any other questions or concerns, please feel
free to let me know. Have a nice day!

Best regards,
Charles Wang
Microsoft Online Community Support
================================================== =========
Delighting our customers is our #1 priority. We welcome your
comments and suggestions about how we can improve the
support we provide to you. Please feel free to let my manager
know what you think of the level of service provided. You can
send feedback directly to my manager at: .
================================================== =========
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for
non-urgent issues where an initial response from the community
or a Microsoft Support Engineer within 1 business day is acceptable.
Please note that each follow up response may take approximately
2 business days as the support professional working with you may
need further investigation to reach the most efficient resolution.
The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by
contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
================================================== ==========
This posting is provided "AS IS" with no warranties, and confers no
rights.
================================================== =======




  #6  
Old May 2nd, 2008, 03:26 AM posted to microsoft.public.access.forms
Charles Wang [MSFT]
external usenet poster
 
Posts: 68
Default Checkbox values at run time

Hi Rockn,
Thank you for your response.

I am glad to hear that the suggestions are helpful. If you have any other
questions or concerns, please feel free to let me know.

Have a nice day!

Best regards,
Charles Wang
Microsoft Online Community Support
================================================== =======
Delighting our customers is our #1 priority. We welcome your
comments and suggestions about how we can improve the
support we provide to you. Please feel free to let my manager
know what you think of the level of service provided. You can
send feedback directly to my manager at: .
================================================== =======
This posting is provided "AS IS" with no warranties, and confers no rights.
================================================== =======




 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 05:32 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.