Can anybody help? I have this code i have put together so that when i select values for my combo boxes which are linked to values in lookup tables, it opens my "frmriskass" with only the corresponding records based on a query i have built in to the code below which is applied to the search command button in my search form.
Private Sub Command4_Click()
DoCmd.OpenForm "frmriskass", acNormal, "qrysearchriskass", , acFormReadOnly
Me.Area = ""
End Sub
It works fine when there is a matching record, but the problem i have is when there is no corresponding record. All i get is a blank form whith no fields or command buttons on it.
How do i change the code so that if there are no corresponding records i will get a message box which says something like "No corresponding record, please search again" and instead of a blank form being opened i can click Ok and go back to my original search form to try again?
11 6740
Sorry. Just realised i had code as acFormReadOnly but have changed this to acFormEdit so i can still input in to the appropriate records found, however if there is no corresponding record i know just get an empty form ready to be completed. Still need code so this doesn't happen.
Can anybody help? I have this code i have put together so that when i select values for my combo boxes which are linked to values in lookup tables, it opens my "frmriskass" with only the corresponding records based on a query i have built in to the code below which is applied to the search command button in my search form.
Private Sub Command4_Click()
DoCmd.OpenForm "frmriskass", acNormal, "qrysearchriskass", , acFormReadOnly
Me.Area = ""
End Sub
It works fine when there is a matching record, but the problem i have is when there is no corresponding record. All i get is a blank form whith no fields or command buttons on it.
How do i change the code so that if there are no corresponding records i will get a message box which says something like "No corresponding record, please search again" and instead of a blank form being opened i can click Ok and go back to my original search form to try again?
Can you post the sql for the filter.
The sql i have for this filter is below:
SELECT tblRiskAss.ReferenceNumber, tblRiskAss.RiskAssessorsName, tblRiskAss.[Hospice Premesis], tblRiskAss.Area, tblRiskAss.Date, tblRiskAss.[Hazard Group Name], tblRiskAss.[State Problem and Risk], tblRiskAss.[Risk Level], tblRiskAss.[Action Taken], tblRiskAss.[Management Status], tblRiskAss.[Person at Risk], tblRiskAss.[Risk Communicated To], tblRiskAss.[Assessment Review Period], tblRiskAss.[Frequency of Monitoring], tblRiskAss.AssessmentReviewDate, tblRiskAss.[Last Reviewed], tblRiskAss.NextReviewDate, tblRiskAss.Completed, tblRiskAss.ysnSentByMailToStaff
FROM tblRiskAss
WHERE (((tblRiskAss.RiskAssessorsName)=[Forms]![frmsearchriskass]![RiskAssessorsName]) AND ((tblRiskAss.Area)=[Forms]![frmsearchriskass]![Area]));
It filters for matching [Risk Assessors Name] and [Area].
Just not sure why it still brings up a blank form ready for data input if no matches for this filter or if there are matches you get the matching record plus a blank one to complete if you scroll with the mouse wheel.
Hope you can help.
Thanks
Thanks for that. It will come in handy in other parts of my database.
I can't apply it to this as my search may find more than one record so being able to scroll is useful.
I just can't get my head around why the code with the filter i have either turns up all matching records plus one blank record or if there are no matches for the filters i have used to search for then all i get is a blank record.
Any ideas?
Thanks for that. It will come in handy in other parts of my database.
I can't apply it to this as my search may find more than one record so being able to scroll is useful.
I just can't get my head around why the code with the filter i have either turns up all matching records plus one blank record or if there are no matches for the filters i have used to search for then all i get is a blank record.
Any ideas?
Set the forms Allow Additions property to No
Thanks. I tried this but it doesn't make any difference. Grrrh! I still get the corresponding records displayed as the forms when i run the code but with addition of this one blank form ready for data entry. Or if there are no matches, just one blank form, ready for data entry.
Thanks for any more help you can give with this. Is it my code? or is it my filter?
Thanks. I tried this but it doesn't make any difference. Grrrh! I still get the corresponding records displayed as the forms when i run the code but with addition of this one blank form ready for data entry. Or if there are no matches, just one blank form, ready for data entry.
Thanks for any more help you can give with this. Is it my code? or is it my filter?
Honestly don't know why this is happening
I am a bit lost with it also. Thanks for all the bits of advice though. I suppose i can't solve every problem i encounter.
Thanks again
I am a bit lost with it also. Thanks for all the bits of advice though. I suppose i can't solve every problem i encounter.
Thanks again
Just tried this, and I think it solves your problem. Set your form to not allow additions and then put the following in the onopen event of your form -
Private Sub Form_Open(Cancel As Integer)
-
Dim rs As Recordset
-
Set rs = Me.RecordsetClone
-
If rs.RecordCount = 0 Then
-
MsgBox "No Data, Try again"
-
DoCmd.Close
-
End If
-
End Sub
-
Thanks for this. I have given it a try but no luck.
Thanks anyway
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Jim Little |
last post by:
In Visual Studio 2003 I was getting a "No files were found to look in" error
while doing searches that included the entire solution, a file mask of "*.*"
and some text with no special checkboxes...
|
by: amywolfie |
last post by:
I would like to place a Find button on a form which uses the built-in
Access Find facility. If no records are found, I would like to display
a custom "no records found - plesae try again" message...
|
by: amywolfie |
last post by:
I would like to put code behind a Find button on a form which:
1) Performs a find based on a field on the form
2) If NO RECORDS ARE FOUND, then displays a custom "No Records Found" message box.
...
|
by: Dmitriy Lapshin [C# / .NET MVP] |
last post by:
Hi all,
I think the VB .NET compiler should at least issue a warning when a function
does not return value. C# and C++ compilers treat this situation as an error
and I believe this is the right...
|
by: Kim |
last post by:
How can I display "No data found" in the repeater if there are no records
found after selecting an item from a dropdown list.
Another question is: Can repeater perform paging as in datagrid if...
|
by: webonomic |
last post by:
"The connection name 'LocalSqlServer' was not found in the applications
configuration or the connection string is empty."
I get the error above. It tells me the error is in
Line 120: ...
|
by: scottmachado |
last post by:
I am currently running a marco that run a query and emails the results
as an attachment in excel format. If the query has no records, I would
like to email "no records found" in the first cell in...
|
by: martin |
last post by:
Hello,
Could someone here please explain the reason for the error in the
subject (the full error below)
I dont get this everytime and i've never gotten while debugging. The
code (also below)...
|
by: RN1 |
last post by:
Sub Page_Load(........)
If Not Page.IsPostBack Then
Call LoadData()
End If
End Sub
Sub LoadData()
Dim dSet As DataSet
Dim sqlConn As SqlConnection
Dim sqlDapter As SqlDataAdapter
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |