Want Form A field to flood into Form B Field

hardhitter06

Registered User.
Local time
Today, 08:11
Joined
Dec 21, 2006
Messages
600
Hi,

I'm trying to flood the ContractNo from FormA into the ContractNo for FormB with an onclick command.

My syntax is probably off and was wondering if someone could assit?

Code:
 stDocName = "FormBSearch"
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    [COLOR="Red"]Forms!FormBSearch!Me.ContractNo = Me.FormB.ContractNo[/COLOR]
    DoCmd.Close acForm, "SearchFormAFormB"

SearchFormAFormB is where the number is coming from.
FormBSearch is where I would like the field data to display

Thank you
 
Hello hardhitter06, you are using DoCmd.OpenForm method, but there is no stLinkCriteria defined? Is that something you have missed or is the criteria below is the one you are trying to use?

Also you say FormBSearch, but the code does not speak anything of it. This is how it should actually be.
Code:
DoCmd.OpenForm "FormBSearch", _
               WhereCondition:="[B][COLOR=Red]theControlOnFormBSearch [/COLOR][/B]= " & Me.[B][COLOR=Blue]ContractNumberControlOnFormA[/COLOR][/B]
 
I just re-read your question, do you want to pass the contract number from FormA to FormB? If so use OpenArgs method.
Code:
DoCmd.OpenForm "yourFormName", OpenArgs:= Me.ContractNumberControlOnFormA
In the Form Load/Current you can check if the OpenArg is set or not. If set, then use that as the value for the control on FormB.
Code:
Private Sub Form_Current()
    If Len(Me.OpenArgs & vbNullStirng) = 0 Then _
        Me.yourFormBControlName = Me.OpenArgs
End Sub
Or am I not understanding your requirement properly?
 
I just want the ContractNo from the first search on the first form to show up in the ContractNo field on the 2nd form from the 2nd search.

Basically FormA's ContractNo to flood into FormB's ContractNo.
 
Okay ! That's what I thought, check the Post#3 I posted it while you were responding to this thread. :p
 
Thanks Paul but it isn't working

Code:
Private Sub Command56_Click()
DoCmd.OpenForm "FormBSearch", OpenArgs:=Me.ContractNo
End Sub



Code:
Private Sub Form_Current()
If Len(Me.OpenArgs & vbNullStirng) = 0 Then _
        Me.ContractNo = Me.OpenArgs
End Sub
 
Me and my silly coding. Lol. Change the = to <> it needs to be not equals 0. Sorry.
Code:
Private Sub Form_Current()
If Len(Me.OpenArgs & vbNullStirng) [COLOR=Red][B]<>[/B][/COLOR] 0 Then _
        Me.ContractNo = Me.OpenArgs
End Sub
Just to be clear, the FormCurrent will be for FormB, also depending on the need you might need to consider moving it into another method like Open or Load. As the way the Form Current works is it will be triggered everytime it navigates to a record.
 

Users who are viewing this thread

Back
Top Bottom