Question : How to get value

I have datacombo with Group_Name
What i want is whatever data in datacombo, how can i get one by one Group_Name in variable
      T_Gname =                            
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
If GName.State = 1 Then GName.Close
        
        GName.Open "Select Name from Groups order by Name", con, adOpenKeyset, adLockOptimistic

        If GName.RecordCount > 0 Then
        
            For Gi = 1 To GName.RecordCount

                GCount = Val(DataCombo4.text) + 1
                Gc = DataCombo4.text + Chr(DataCombo4.text)
            Next Gi
                        
        End If
    Exit Sub

Answer : How to get value

ok there are a few ways to do what i think you want to do.  

1: prob the easist way is to use a report instead of a form.

2: if you are going to use a form in the onclick event of your button you can use one of these two sets of code.

'------------------code one -----place in your on click event
Dim response As String
Dim mysql As String
Dim cboval As String
Dim i As Integer
i = 0
With Me.Combo1 'Change to your combobox name
        .SetFocus
        For i = 0 To .ListCount - 1
     cboval = .Column(0, i)
    response = MsgBox("Print records for " & Me.Combo1.Column(0, i) & "?", vbYesNo)
    If response = vbYes Then
            mysql = "SELECT * FROM Table1 WHERE table1.CUSTOMERNAME = " & "'" & cboval & "'" & " ;"   'change table1 to your table/query name - change cutormername to your column name"
            Me.Form.RecordSource = mysql
            DoCmd.RunCommand acCmdPrint
            End If
        Next i
    End With



'-------------------end of code one-------------------
or you could use the below code instead

'--------------code two place in the on click event of your button
Dim response As String
Dim mysql As String
Dim cboval As String
Dim i As Integer
i = 0
mysql = ""

With Me.Combo1 'Change to your combobox name
        .SetFocus
        For i = 0 To .ListCount - 1
        cboval = .Column(0, i)
        If mysql = "" Then
        mysql = mysql & "' table1.CUSTOMERNAME = " & cboval & "'"  ' change table1 to your table/query name and change customername to your column name
        Else
        mysql = mysql & "' OR table1.CUSTOMERNAME = " & cboval & "'" ' change table1 to your table/query name and change customername to your column name

        End If
             
        Next i
        mysql = "SELECT * FROM Table1 WHERE " & mysql & " ;"    'change table1 to your table/query name - change cutormername to your column name"
            Me.Form.RecordSource = mysql
            DoCmd.RunCommand acCmdPrint
   
    End With

'--------------end of code two
Random Solutions  
 
programming4us programming4us