Solved

using a form as parameter

Posted on 2003-10-31
3
142 Views
Last Modified: 2010-05-01
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
0
Comment
Question by:RonaldBiemans
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 52

Accepted Solution

by:
Ryan Chong earned 125 total points
ID: 9657109
Make sure the object/ variable in this sub is defined as Public, like:

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

to

public sub AlterQ(Frm1 As Form, Soort As Byte)
0
 
LVL 1

Expert Comment

by:JonGartzia
ID: 9657871
Try this:

private sub AlterQ(Frm1 As Object, Soort As Byte)
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 9658034
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
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

691 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