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 / New Users / April 2006

Tip: Looking for answers? Try searching our database.

Complicated Form-Query-Form Problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
crs232 - 21 Apr 2006 15:29 GMT
I've created a form (frmComboSearch) with combo boxes for various fields from
a table (tblMasterPartsList).  After selecting the values from the combo
boxes, a query (qryComboSearch) is run using the data from the combo boxes.  
This is all activated by a command button.  What I'm trying to do is have a
new form open after the command button is pushed, instead of opening the
query.  I've created a form (frmqryComboSearch) to display the query results,
and everything is working fine.  The one problem i've run into is that I want
a dialogue box to pop up if there are no record matches for the query,
stating such, and giving the user a command button to return to the original
form with the combo boxes.  So far, i've tried:

1.  the On_Open Event in the second form (frmqryComboSearch):

   If Me.RecordsetClone.RecordCount = 0 Then
       MsgBox "Sorry, there are no Parts that match your search criteria."
       Cancel = True
   End If

the dialogue pops up fine, but when it tries to go back to the original
form, i get the error message "Run-time error'2501':  The OpenForm action was
canceled."

2. the On_Click Event of the command button in the first form
(frmComboSearch):

Private Sub cmdSearch_Click()
   If Me.RecordsetClone.RecordCount = 0 Then
       MsgBox "Sorry, there are no Parts that match your search criteria."
       Cancel = True
   End If
   
   DoCmd.OpenForm "frmqryComboSearch", acNormal
   DoCmd.Close acForm, "frmComboSearch"
End Sub

Which returns the error message "Run-time error '7951':  You entered an
expression that has an invalid reference to the RecordsetClone property."

I'm not sure what else to try... any help would be greatly appreciated!
Klatuu - 21 Apr 2006 15:41 GMT
Change this line
If Me.RecordsetClone.RecordCount = 0 Then
To
If Me.Recordset.RecordCount = 0 Then

I don't know for sure if this is true for forms, but I know it is required
for reports.  If you cancel the Open event, even using the Cancel, the
calling form will raise an error and you have to trap for it.  So try
trapping for it in the error handler for cmdSearch_Click().

> I've created a form (frmComboSearch) with combo boxes for various fields from
> a table (tblMasterPartsList).  After selecting the values from the combo
[quoted text clipped - 35 lines]
>
> I'm not sure what else to try... any help would be greatly appreciated!
 
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.