Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / February 2006

Tip: Looking for answers? Try searching our database.

setting query criteria from a form  (I don't know what to call thi

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
westaj - 01 Feb 2006 17:17 GMT
I have a query named [qryStudyAllInterested].  There are no criteria for this
query, it is used to combine two tables into one query. I have created a form
named [frmStudyAllInterestedSelect] that has one button named
[btnStudyAllInterested] and one lookup field named [cbxStudyID] that does not
have a control source.

I would like to select a study from a drop down list using the [cbxStudyID]
field.  Then press the [btnStudyAllInterested] button. Upon pressing this
button I would like Access to open a different form named
[frmStudyAllInterested] that is in tabular view and linked (record source) to
the [qryStudyAllInterested] query.

I have written VBA code (see what follows).  But when I select a study from
the [cbxStudyID] drop box and then click on the [btnStudyAllInterested]
button I receive the following error.  

"Syntax error (missing operator) in query expression '[StudyID]= "the value
selected in the [cbxSudyID] drop box displays here"'"  

PLEASE HELP.

VBA programmed to the button [btnStudyAllInterested]:

Private Sub btnStudyAllInterested_Click()
On Error GoTo Err_FilterIssues_Click

   Dim stDocName As String
   Dim stLinkCriteria As String
   
   stDocName = "frmStudyAllInterested"
   stLinkCriteria = "[StudyID]=" & cbxStudyID

   If DCount("StudyID", "qryStudyAllInterested", stLinkCriteria) Then
   DoCmd.OpenForm stDocName, , , stLinkCriteria
   ' Close the dialog box.
   DoCmd.Close acForm, "frmStudyAllInterestedSelect"
   End If

Exit_btnStudyAllInterested_Click:
   Exit Sub

Err_FilterIssues_Click:
   MsgBox Err.Description
   Resume Exit_btnStudyAllInterested_Click

End Sub
westaj - 02 Feb 2006 20:58 GMT
Boy was I far off.  heh.  I was making this much more difficult than I needed
to.  This is the VBA:

Private Sub btnStudyAllInterestedSelect1_Click()
On Error GoTo Err_btnStudyAllInterestedSelect1_Click

   Dim stDocName As String
   Dim stLinkCriteria As String

   stDocName = "frmStudyAllInterested"
   
   stLinkCriteria = "[StudyID]=" & "'" & Me![cbxStudyID] & "'"
   DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_btnStudyAllInterestedSelect1_Click:
   Exit Sub

Err_btnStudyAllInterestedSelect1_Click:
   MsgBox Err.Description
   Resume Exit_btnStudyAllInterestedSelect1_Click
   
End Sub

> I have a query named [qryStudyAllInterested].  There are no criteria for this
> query, it is used to combine two tables into one query. I have created a form
[quoted text clipped - 42 lines]
>
> End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.