Setting form properties from another form gives nothing

nemPyong

Registered User.
Local time
Today, 15:32
Joined
Jul 5, 2013
Messages
18
So I have two forms: Af and Bf

In Af, when a button, Abtn, clicked, it'll run
Code:
   Me.Visible = False
   DoCmd.OpenForm "Bf", , , , acFormEdit
   Forms![Bf].Form!Blabel.Caption = Me.Atxtbox
   Forms![Bf].Form!Bcombox = Me.Atxtbox
Then Af lost from view and Bf appears in form view, with Blabel and Bcombox show the value of Atxtbox.

BUT if I try something like this in Bf when an event happens
Code:
   Me.Bcombox2.RowSource = "SELECT xx FROM tablexx WHERE yy = '" & Nz(Me.Bcombox) & "'"
Nothing will be shown in Bcombox2, because Me.Bcombox return Null. I know this from doing
Code:
   MsgBox Me.Bcombox
and the message box will shows nothing. The same thing also happen with the Blabel's caption. In form view, it shows Atxtbox value, but when I accessed its caption's value, it returns Null.

What I wanna do is:
1) Open Af, insert value to Atxtbox
2) clicked Abtn, pass the value of Atxtbox to Bcombox
3) Af is closed, and Bf is opened

Why the null...? :confused:
 
nemPyong, Make sure that the value you pass to the second form's combo box exists in its RowSource..
 
nemPyong, Make sure that the value you pass to the second form's combo box exists in its RowSource..

Actually, in the real form, Atxtbox is a combobox.
And Atxtbox and Bcombox have the same RowSource.
So, everything exists in Atxtbox should also exists in Bcombox...

And when I passed the value of Atxtbox to Blabel as its caption (caption of label should accept any regular string, right?), still it's null...
 
Try this..
Code:
   DoCmd.OpenForm "Bf", DataMode:= acFormEdit, OpenArgs:= Me.Atxtbox
   Me.Visible = False
Then in the Form Open method..
Code:
Private Sub Form_Open(Cancel As Integer)
    If Len(Me.OpenArgs & vbNullString) <> 0 Then
        Me.Blabel.Caption = Me.OpenArgs
        Me.Bcombox = Me.OpenArgs
    End If
End Sub
 
Try this..
Code:
   DoCmd.OpenForm "Bf", DataMode:= acFormEdit, OpenArgs:= Me.Atxtbox
   Me.Visible = False
Then in the Form Open method..
Code:
Private Sub Form_Open(Cancel As Integer)
    If Len(Me.OpenArgs & vbNullString) <> 0 Then
        Me.Blabel.Caption = Me.OpenArgs
        Me.Bcombox = Me.OpenArgs
    End If
End Sub

GYAAAA it woooorks
HE.RO. Thank you so so so very much!
I've spent hot day and cold night in this problem...
It passed the param to the next form beautifully :)
Again, Sir, thank you so very much!
peluk_zpse5cd959a.png


Problem solved! :o
 

Users who are viewing this thread

Back
Top Bottom