I have a form.
When a person selects a publication from a listbox, this snippet of
code is supposed to look up authors that correspond to that publication
and populate the Author List Box, but it doesn't work. I have been
hacking away at it for a while to no avail. Can anyone spot the bug(s)?
The RowSource property of Authors gets set to the following by this
code, if that helps you help me:
SELECT Author FROM Authors WHERE [Publication 1]=127 Or [Publication
2]=127 Or [Publication 3]=127;
Private Sub Publication_Aft erUpdate()
Dim dbsCurrent As Database
Dim rstPublications As Recordset
Dim qdfExists As QueryDef
Dim intPublication As Integer
Dim intPubMasterID As Integer
Set dbsCurrent = OpenDatabase("c :\documents and
settings\admini strator\desktop \PR.mdb")
intPublication = [Forms]![new clips]!Publication
Set qdfExists = dbsCurrent.Crea teQueryDef("")
With qdfExists
.SQL = "SELECT * FROM Publications " & _
"WHERE PublicationID = " & intPublication
Set rstPublications = .OpenRecordset( )
End With
With rstPublications
intPubMasterID = !PubMasterID
End With
rstPublications .Close
Set qdfExists = dbsCurrent.Crea teQueryDef("")
With qdfExists
.SQL = "SELECT Author FROM Authors " & _
"WHERE [Publication 1] = " & intPubMasterID & _
"OR [Publication 2] = " & intPubMasterID & _
"OR [Publication 3] = " & intPubMasterID
End With
Me.Author.RowSo urce = qdfExists.SQL
Me.Author.Reque ry
dbsCurrent.Clos e
End Sub
Thanks!
Andrew
When a person selects a publication from a listbox, this snippet of
code is supposed to look up authors that correspond to that publication
and populate the Author List Box, but it doesn't work. I have been
hacking away at it for a while to no avail. Can anyone spot the bug(s)?
The RowSource property of Authors gets set to the following by this
code, if that helps you help me:
SELECT Author FROM Authors WHERE [Publication 1]=127 Or [Publication
2]=127 Or [Publication 3]=127;
Private Sub Publication_Aft erUpdate()
Dim dbsCurrent As Database
Dim rstPublications As Recordset
Dim qdfExists As QueryDef
Dim intPublication As Integer
Dim intPubMasterID As Integer
Set dbsCurrent = OpenDatabase("c :\documents and
settings\admini strator\desktop \PR.mdb")
intPublication = [Forms]![new clips]!Publication
Set qdfExists = dbsCurrent.Crea teQueryDef("")
With qdfExists
.SQL = "SELECT * FROM Publications " & _
"WHERE PublicationID = " & intPublication
Set rstPublications = .OpenRecordset( )
End With
With rstPublications
intPubMasterID = !PubMasterID
End With
rstPublications .Close
Set qdfExists = dbsCurrent.Crea teQueryDef("")
With qdfExists
.SQL = "SELECT Author FROM Authors " & _
"WHERE [Publication 1] = " & intPubMasterID & _
"OR [Publication 2] = " & intPubMasterID & _
"OR [Publication 3] = " & intPubMasterID
End With
Me.Author.RowSo urce = qdfExists.SQL
Me.Author.Reque ry
dbsCurrent.Clos e
End Sub
Thanks!
Andrew
Comment