Solved

using a form as parameter

Posted on 2003-10-31
3
130 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
3 Comments
 
LVL 49

Accepted Solution

by:
Ryan Chong earned 125 total points
Comment Utility
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
Comment Utility
Try this:

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

Expert Comment

by:GrahamSkan
Comment Utility
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now