How can i link a field to an unbound field in a different form, in Access 2000?

Using "=Forms!Formname!Fieldname" in the control source doesn’t work, Access automatically inserts [] around the form and field names redering it useless. Is there another way of doing this?

you can go to form view of that form and type

Me.FieldName2.Value = Forms!FormName!FieldName1.Value

Say you have a form named "Users" and a subform named "UsersSub" with a textbox with a name of "UserName"

Code:
Dim UserName As String
My_UserName = Forms!Users!UserName.Value

MsgBox(My_UserName)

The key to the whole operation is "Forms!Form_Name!Input_name"

If the data you need is in the same for or subform all you have to do is

Code:
Dim UserName As String
My_UserName = Me!UserName.Value
MsgBox(My_UserName)

"Me!" is saying the current focused form name/object

Here is a simple usage. Say you have a form of users and you are tracking them by location and what time to contact them and you want to view all the people to call during the day time. You want to click on their name in the subform and have their contact information open in a new form.
The main form’s name is "Users" and the subform textbox name is named "Info"

Code:
Option Compare Database

Private Sud Info_Click()
Dim UserName As String
Dim Contact_Time As String

UserName = Forms!Users!UserName.Value
Contact_Time = Me!Info.Value

‘Now we open a new form
‘Search for that person with that user name and contact time
‘The newly open form’s name is "UserInfo"

‘Define the form to open
Dim NewFormName As String
NewFormName = "UserInfo"

‘Set the username and contact time criteria
Dim Criteria_ As String

‘[] is the field name in the database table
Criteria_ = "[UserName]=" & "’" & UserName &"’ AND [Contact_Time]=" & "’" & Contact_Time & "’"
DoCmd.OpenForm NewFormName, acNormal, Criteria_, acFormEdit, acWindowNormal

End Sub

See viewtopic.php?f=4&t=97 for more DoCmd

One Response to “How can i link a field to an unbound field in a different form, in Access 2000?”

  1. DzSoundNirvana Says:

    you can go to form view of that form and type

    Me.FieldName2.Value = Forms!FormName!FieldName1.Value

    Say you have a form named "Users" and a subform named "UsersSub" with a textbox with a name of "UserName"

    Code:
    Dim UserName As String
    My_UserName = Forms!Users!UserName.Value

    MsgBox(My_UserName)

    The key to the whole operation is "Forms!Form_Name!Input_name"

    If the data you need is in the same for or subform all you have to do is

    Code:
    Dim UserName As String
    My_UserName = Me!UserName.Value
    MsgBox(My_UserName)

    "Me!" is saying the current focused form name/object

    Here is a simple usage. Say you have a form of users and you are tracking them by location and what time to contact them and you want to view all the people to call during the day time. You want to click on their name in the subform and have their contact information open in a new form.
    The main form’s name is "Users" and the subform textbox name is named "Info"

    Code:
    Option Compare Database

    Private Sud Info_Click()
    Dim UserName As String
    Dim Contact_Time As String

    UserName = Forms!Users!UserName.Value
    Contact_Time = Me!Info.Value

    ‘Now we open a new form
    ‘Search for that person with that user name and contact time
    ‘The newly open form’s name is "UserInfo"

    ‘Define the form to open
    Dim NewFormName As String
    NewFormName = "UserInfo"

    ‘Set the username and contact time criteria
    Dim Criteria_ As String

    ‘[] is the field name in the database table
    Criteria_ = "[UserName]=" & "’" & UserName &"’ AND [Contact_Time]=" & "’" & Contact_Time & "’"
    DoCmd.OpenForm NewFormName, acNormal, Criteria_, acFormEdit, acWindowNormal

    End Sub

    See viewtopic.php?f=4&t=97 for more DoCmd
    References :
    http://bb.dzsoundnirvana.com/viewtopic.php?f=4&t=98

Leave a Reply