bind an unbound text box, based on on click results, to a query

T

Tracy

I have an unbound text box named Text62 with its' records source set as
=Forms!Home!List0
on a form named f_PrimaryEntry that populates the text box based upon the
selection on the prior screen from a form named Home that utilizes two
command buttons named Command2 and Command3. The code for the selection from
the command buttons, which pulls the year selected or SFY on the 'on click'
event for each button is as follows respectively:
Private Sub Command2_Click()
Private Sub Form_Open(Cancel As Integer)
Dim db As Database
Dim qdf As QueryDef
Set db = CurrentDb
Set qdf = db.QueryDefs("q_subs2")
Set items = qdf.OpenRecordset
With items
Command2.Caption = .Fields(2)
Command3.Caption = .Fields(3)
While Not .EOF
List0.AddItem (.Fields(1))
.MoveNext
Wend
End With

List0_Click
End Sub

Private Sub List0_BeforeUpdate(Cancel As Integer)

End Sub

DoCmd.OpenForm "f_PrimaryEntryScreen"

Dim stDocName As String
Dim stLinkCriteria As String


stDocName = "f_PrimaryEntryScreen"

stLinkCriteria = "[SFY]=" & items(2)
DoCmd.OpenForm stDocName, , , stLinkCriteria

End Sub

Private Sub Command3_Click()

DoCmd.OpenForm "f_PrimaryEntryScreen"


Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "f_PrimaryEntryScreen"

stLinkCriteria = "[SFY]=" & items(3)
DoCmd.OpenForm stDocName, , , stLinkCriteria

End Sub

I need to dynamically pull on a query the selection made for the SFY. I
have entered the criteria [Form]![Home]![& items 2] Or [Form]![Home]![& items
3] and though it does give me the correct year, it also pops up the parameter
box as if it's looking for criteria to be entered. There's got to be a way
to pull this info in. Can anyone help me with this one please?

Thanks.

Tracy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top