Want Form A field to flood into Form B Field (1 Viewer)

hardhitter06

Registered User.
Local time
Today, 04:51
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
 

pr2-eugin

Super Moderator
Local time
Today, 09:51
Joined
Nov 30, 2011
Messages
8,494
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]
 

pr2-eugin

Super Moderator
Local time
Today, 09:51
Joined
Nov 30, 2011
Messages
8,494
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?
 

hardhitter06

Registered User.
Local time
Today, 04:51
Joined
Dec 21, 2006
Messages
600
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.
 

pr2-eugin

Super Moderator
Local time
Today, 09:51
Joined
Nov 30, 2011
Messages
8,494
Okay ! That's what I thought, check the Post#3 I posted it while you were responding to this thread. :p
 

hardhitter06

Registered User.
Local time
Today, 04:51
Joined
Dec 21, 2006
Messages
600
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
 

pr2-eugin

Super Moderator
Local time
Today, 09:51
Joined
Nov 30, 2011
Messages
8,494
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

Top Bottom