Setting field in another form

  • Thread starter Thread starter Bill
  • Start date Start date
B

Bill

Can't seem to get the syntax correct for the assignment
statement seen in Sub tbMov3_LostFocus. I need to
set the corresponding text box in the calling form after
focus moves from one control to another. (Only
pertinent code posted below)

Option Compare Database
Option Explicit
Dim strCallingForm As String

Private Sub Form_Open(Cancel As Integer)
Dim Atmp() As String
Dim strStartField As String
'============================================================
' OpenArgs contains the name of the "calling" form and the control name on
that form that
' currently has the focus, separated by a semicolon. There is a one-to-one
correspondance
' between the text box controls on the current and calling forms.
'============================================================
Atmp = Split(Me.OpenArgs, ";")
strStartField = Trim(Atmp(1))
strCallingForm = Trim(Atmp(0))
Me.Controls(strStartField).SetFocus

End Sub
-------------------------------------------------------------------------------------------
Private Sub tbMov3_LostFocus()
If Len(Trim(Me.tbMov3)) > 0 Then
Forms![strCallingForm].Form!Controls("tbmov3") = Me.tbMov3

End Sub
------------------------------------------------------------------------------------------
 
Can't seem to get the syntax correct for the assignment
statement seen in Sub tbMov3_LostFocus. I need to
set the corresponding text box in the calling form after
focus moves from one control to another. (Only
pertinent code posted below)

Option Compare Database
Option Explicit
Dim strCallingForm As String

Private Sub Form_Open(Cancel As Integer)
Dim Atmp() As String
Dim strStartField As String
'============================================================
' OpenArgs contains the name of the "calling" form and the control name on
that form that
' currently has the focus, separated by a semicolon. There is a one-to-one
correspondance
' between the text box controls on the current and calling forms.
'============================================================
Atmp = Split(Me.OpenArgs, ";")
strStartField = Trim(Atmp(1))
strCallingForm = Trim(Atmp(0))
Me.Controls(strStartField).SetFocus

End Sub
-------------------------------------------------------------------------------------------
Private Sub tbMov3_LostFocus()
If Len(Trim(Me.tbMov3)) > 0 Then
Forms![strCallingForm].Form!Controls("tbmov3") = Me.tbMov3

End Sub
------------------------------------------------------------------------------------------

You're almost there! Just change the last line to this:
Forms(strCallingForm).tbmov3 = Me.tbMov3

(and don't forget "End If" if this is really on a separate line.)
 
Great! I tried to find syntax references regarding the
forms collection, but seemed to find everything but.
Was that particular syntax available in A2K?
Bill

Can't seem to get the syntax correct for the assignment
statement seen in Sub tbMov3_LostFocus. I need to
set the corresponding text box in the calling form after
focus moves from one control to another. (Only
pertinent code posted below)

Option Compare Database
Option Explicit
Dim strCallingForm As String

Private Sub Form_Open(Cancel As Integer)
Dim Atmp() As String
Dim strStartField As String
'============================================================
' OpenArgs contains the name of the "calling" form and the control name on
that form that
' currently has the focus, separated by a semicolon. There is a one-to-one
correspondance
' between the text box controls on the current and calling forms.
'============================================================
Atmp = Split(Me.OpenArgs, ";")
strStartField = Trim(Atmp(1))
strCallingForm = Trim(Atmp(0))
Me.Controls(strStartField).SetFocus

End Sub
-------------------------------------------------------------------------------------------
Private Sub tbMov3_LostFocus()
If Len(Trim(Me.tbMov3)) > 0 Then
Forms![strCallingForm].Form!Controls("tbmov3") = Me.tbMov3

End Sub
------------------------------------------------------------------------------------------

You're almost there! Just change the last line to this:
Forms(strCallingForm).tbmov3 = Me.tbMov3

(and don't forget "End If" if this is really on a separate line.)
 
Great! I tried to find syntax references regarding the
forms collection, but seemed to find everything but.
Was that particular syntax available in A2K?
Bill

It was in Access 97 already, or even as early as Access 2 -- but you
needed to always use the bang instead of the dot in Access 2, IIRC.
 
Back
Top