Results 1 to 7 of 7

Thread: Multi forms and a module

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2000
    Location
    Columbus, OH
    Posts
    22
    Hello all...

    Just started taking interest in VB... My question is how do you code form1's optionbox value to show it's caption in form2??? I did add a module and declared the connector but it's not working.... can anybody help me out on this.... my lab is due Tuesday (9.24.00)...

    Thanks,

    Eena
    Eena

  2. #2
    Guest
    Try this:

    [code]

    Origionally by Eena
    Just started taking interest in VB... My question is how do you code form1's optionbox value to show it's caption in form2??? I did add a module and declared the connector but it's not working.... can anybody help me out on this.... my lab is due Tuesday (9.24.00)...
    Form2:
    [/quote]
    if form1.option1.value then
    msgbox form1.option1.caption
    end if

  3. #3
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    Welcome to the forums Eena

    If you have your code in an event in Form1, you can use this kind of thing:

    Form2.Label1.Caption = Option1.Caption

    which is a short way of writing this:

    Form2.Label1.Caption = Form1.Option1.Caption


    Basically if you are writing code in a form, the compiler looks for the object you are identifying (eg Label1) in the local form if you don't specify which form it's in. Obviously if it can't find it there is an error. If you specify which form the object is in (eg Form2.Label1) then the compiler should find it okay.

    It's because a form is an object, which contains other objects (like labels and option buttons), which contain their own properties (like Caption and Name). All this is specified using the dot (.) or direct member access operator. It sounds complicated but it's not, you've been using it all the time after all
    Harry.

    "From one thing, know ten thousand things."

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Sep 2000
    Location
    Columbus, OH
    Posts
    22
    Thanks for your prompt response... I applied the form2.label1.caption=option1.caption... and it gave me an error message of object required.. what did i do wrong?

    Here's my code:

    Dim strProcessor As String
    strProcessor = lblProcessor.Caption
    If optWC700.Value = True Then
    frmReceipt.lblProcessor.Caption = optWC700.Caption
    End If

    If optWC500.Value = True Then
    frmReceipt.lblProcessor.Caption = optWC500.Caption
    End If

    If optWC800.Value = True Then
    frmReceipt.lblProcessor.Caption = optWC800.Caption
    End If

    If optWC1000.Value = True Then
    frmReceipt.lblProcessor.Caption = optWC1000.Caption
    End If

    End Sub
    Eena

  5. #5
    Guest
    If optW C100 0.Value = True Then
    frmReceipt.lblProcessor.Caption = optW C100 0.Caption
    End If
    optWC1000 should have no spaces.

    Try removing them...

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Sep 2000
    Location
    Columbus, OH
    Posts
    22
    I'm sorry i sound so dumb... i fixed the spaces but it still gave me the error: object required...

    do i need to declare the optWC700 as object???

    Eena

  7. #7
    Guest
    Code:
    'Your code
    Dim strProcessor As String 
    strProcessor = lblProcessor.Caption '<-- Error
    If optWC700.Value = True Then 
    frmReceipt.lblProcessor.Caption = optWC700.Caption 
    End If 
    
    If optWC500.Value = True Then 
    frmReceipt.lblProcessor.Caption = optWC500.Caption 
    End If 
    
    If optWC800.Value = True Then 
    frmReceipt.lblProcessor.Caption = optWC800.Caption 
    End If 
    
    If optW C100 0.Value = True Then 
    frmReceipt.lblProcessor.Caption = optW C100 0.Caption 
    End If 
    
    End Sub
    strProcessor = [frmReceipt.]lblProcessor.Caption

    You forgot the frmReceipt. at that line.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width