Combo Code Help

  • Thread starter Thread starter Cyndi
  • Start date Start date
C

Cyndi

I have 2 combo box -

Mare - based on a query that pulls marenumber from the stallionseason
table and mare name from the stallionmare table(mare name is not in
stallionseason only ID)

I want second combo box to go to stallionseason table and give me
choices of the years the mare was on the farm seasonyear is a field
in stallionseason table

Here is my code

Private Sub Mare_AfterUpdate()
strSQL = "SELECT SeasonYear FROM StallionSeasonTable" &

"WHERE MareID = "& Me.cboMare & " " &_
"ORDER BY SeasonYear"

With Me.cboSeasonYear
.RowSourceType = "Table/Query"
.RowSource = strsql
End With
End Sub

Private Sub SeasonYear_AfterUpdate()
Dim sSQL As String

'This Function sets the RowSource of cboSeasonYear, based on the
'value selected in cboSeasonYear.
sSQL = "Select MareNumber,SeasonYear"_
& "FROM tblStallionSeason Table WHERE MareNumber =
"&Me.cboSeasonYear
& "ORDER BY SeasonYear"

Me.cboSeasonYear.RowSource = sSQL
'The combo should requery on it's own, but if it doesn't,
'uncomment the next line.
'Me.cboCombo2.Requery 'Requery the Combo

End Sub

Access does not like most of this the both places I have str or sql
are all red - and if you tell me I am missing the _ from the end of
the row access doesnt like when I put this in at all.

Thanks in advance
 
When composing strings over multiple lines, the string on
each line must be complete (i.e. end with " or with a
string variable) and each line must end with & _

Hope That Helps
Gerald Stanley MCSD
 
No I am sorry it didnt help - where do I need the quotation and is the mark at the end an underline because when I put it in it comes back wrong code etc
 
Cyndi

The last character is an underscore. The code should be
something like

strSQL = "SELECT SeasonYear FROM StallionSeasonTable " & _
"WHERE MareID = "& Me.cboMare & " " & _
"ORDER BY SeasonYear"

Hope That Helps
Gerald Stanley MCSD
-----Original Message-----
No I am sorry it didnt help - where do I need the
quotation and is the mark at the end an underline because
when I put it in it comes back wrong code etc
 
Back
Top