Link to home
Start Free TrialLog in
Avatar of RonaldBiemans
RonaldBiemans

asked on

using a form as parameter

I have  several "identical" forms which I try to alter dynamicaly. I tried the following but this doesn't work. It has something to do with the Frm1 as Form but I don't know what

alterq(FrmCust1,1)


private sub AlterQ(Frm1 As Form, Soort As Byte)
Dim x As Byte

Set rsRndVragen = New ADODB.Recordset

rsRndVragen.Open "select * from rndQ where Custid = " & CustID & " and soort = " & Soort, CN, adOpenStatic, adLockReadOnly
rsRndVragen.MoveFirst

With Frm1
    x = 0
    Do While Not rsVragen.EOF
        .Controls("lblvraag1" & "(" & CStr(x) & ")").Caption = rsVragen!vraagtext
        .Controls("Option1" & CStr(x)).Item(0).Caption = rsVragen!antwoord1
        .Controls("Option1" & CStr(x)).Item(1).Caption = rsVragen!antwoord2
        .Controls("Option1" & CStr(x)).Item(2).Caption = rsVragen!antwoord3
        x = x + 1
        rsVragen.MoveNext
    Loop

    rsRndVragen.Close
End With

Set rsRndVragen = Nothing

End sub
ASKER CERTIFIED SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of JonGartzia
JonGartzia

Try this:

private sub AlterQ(Frm1 As Object, Soort As Byte)
I have just tried this using Option buttons as controls & dropping the db connection. It works. Can you say what does happen in your case?
With Frm1
    x = 0
    'Do While Not rsVragen.EOF
        '.Controls("lblvraag1" & "(" & CStr(x) & ")").Caption = rsVragen!vraagtext
        .Controls("Option1" & CStr(x)).Caption = "rsVragen!antwoord1"
        .Controls("Option2" & CStr(x)).Caption = "rsVragen!antwoord2"
        .Controls("Option3" & CStr(x)).Caption = "rsVragen!antwoord3"
        'x = x + 1
        'rsVragen.MoveNext
    'Loop

    'rsRndVragen.Close
End With