A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Default Text for an Empty returned recordset



 
 
Thread Tools Display Modes
  #1  
Old November 8th, 2006, 05:22 PM posted to microsoft.public.access.forms
ricky
external usenet poster
 
Posts: 39
Default Default Text for an Empty returned recordset

Hi

I have a query executed from a command button. The query prompts the user
to supply a variable. If the variable returns no data, how would I place
some default text to tell the user nothing has been returned.

Kind Regards

Ricky


  #2  
Old November 8th, 2006, 05:28 PM posted to microsoft.public.access.forms
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default Default Text for an Empty returned recordset

How are you executing the query? If you're using DoCmd.OpenQuery, then I
don't think there's anything you can do.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"ricky" wrote in message
...
Hi

I have a query executed from a command button. The query prompts the user
to supply a variable. If the variable returns no data, how would I place
some default text to tell the user nothing has been returned.

Kind Regards

Ricky




  #3  
Old November 8th, 2006, 06:41 PM posted to microsoft.public.access.forms
Klatuu
external usenet poster
 
Posts: 7,074
Default Default Text for an Empty returned recordset

First, rather than have the user enter to parameter value in the query, put a
text box on your form and have them enter it there. Then, open the query as
a recordset and test the recordcount property. If it returns 0, not records
are returned.

Change the criteria in your query to reference the control the user where
the user will enter the criteria

Forms!MyFormName!txtSearchValue

Dim dbf As Database
Dim rst As Recordset
Dim qdf as Querydef
Dim lngRecords As Long

Set dbf = Currentdb
Set qdf = dbf.Querydefs("MyQueryNameHere")
qdf.Parameters(0) = Me.txtSearchValue
Set rst = qdf.OpenRecordset(dbOpenSnapshot, dbReadOnly)
lngRecords = rst.RecordCount
rst.Close
Set rst = Nothing
Set qdf = Nothing
Set dbf = Nothing
If lngRecords 1 Then
MsgBox "No Records Found"
Else
'Do whatever you want with the query
End If
rst.MoveLast

rst.Close
set rst = nothing
set dbf = nothing


"ricky" wrote:

Hi

I have a query executed from a command button. The query prompts the user
to supply a variable. If the variable returns no data, how would I place
some default text to tell the user nothing has been returned.

Kind Regards

Ricky



  #4  
Old November 9th, 2006, 11:24 AM posted to microsoft.public.access.forms
ricky
external usenet poster
 
Posts: 39
Default Default Text for an Empty returned recordset

Hi Klatuu

Unfortunately, I have inherited this project from someone who has left the
company and lets just say VBA is not my forte. Thank you for the code
posting, I'll try it out.

Kind Regards

Ricky

"Klatuu" wrote in message
...
First, rather than have the user enter to parameter value in the query,

put a
text box on your form and have them enter it there. Then, open the query

as
a recordset and test the recordcount property. If it returns 0, not

records
are returned.

Change the criteria in your query to reference the control the user where
the user will enter the criteria

Forms!MyFormName!txtSearchValue

Dim dbf As Database
Dim rst As Recordset
Dim qdf as Querydef
Dim lngRecords As Long

Set dbf = Currentdb
Set qdf = dbf.Querydefs("MyQueryNameHere")
qdf.Parameters(0) = Me.txtSearchValue
Set rst = qdf.OpenRecordset(dbOpenSnapshot, dbReadOnly)
lngRecords = rst.RecordCount
rst.Close
Set rst = Nothing
Set qdf = Nothing
Set dbf = Nothing
If lngRecords 1 Then
MsgBox "No Records Found"
Else
'Do whatever you want with the query
End If
rst.MoveLast

rst.Close
set rst = nothing
set dbf = nothing


"ricky" wrote:

Hi

I have a query executed from a command button. The query prompts the

user
to supply a variable. If the variable returns no data, how would I

place
some default text to tell the user nothing has been returned.

Kind Regards

Ricky





  #5  
Old November 9th, 2006, 02:01 PM posted to microsoft.public.access.forms
Klatuu
external usenet poster
 
Posts: 7,074
Default Default Text for an Empty returned recordset

There is one line that needs to be removed.
rst.MoveLast
I don't know how it got there. Copy/Paste can be a dangerous thing.

Post back if you need more help with it.

I also suggest you learn VBA. You can create a workable database without
it, but you will be limited in what you can do. It really isn't that hard to
do.

"ricky" wrote:

Hi Klatuu

Unfortunately, I have inherited this project from someone who has left the
company and lets just say VBA is not my forte. Thank you for the code
posting, I'll try it out.

Kind Regards

Ricky

"Klatuu" wrote in message
...
First, rather than have the user enter to parameter value in the query,

put a
text box on your form and have them enter it there. Then, open the query

as
a recordset and test the recordcount property. If it returns 0, not

records
are returned.

Change the criteria in your query to reference the control the user where
the user will enter the criteria

Forms!MyFormName!txtSearchValue

Dim dbf As Database
Dim rst As Recordset
Dim qdf as Querydef
Dim lngRecords As Long

Set dbf = Currentdb
Set qdf = dbf.Querydefs("MyQueryNameHere")
qdf.Parameters(0) = Me.txtSearchValue
Set rst = qdf.OpenRecordset(dbOpenSnapshot, dbReadOnly)
lngRecords = rst.RecordCount
rst.Close
Set rst = Nothing
Set qdf = Nothing
Set dbf = Nothing
If lngRecords 1 Then
MsgBox "No Records Found"
Else
'Do whatever you want with the query
End If
rst.MoveLast

rst.Close
set rst = nothing
set dbf = nothing


"ricky" wrote:

Hi

I have a query executed from a command button. The query prompts the

user
to supply a variable. If the variable returns no data, how would I

place
some default text to tell the user nothing has been returned.

Kind Regards

Ricky






  #6  
Old November 9th, 2006, 02:54 PM posted to microsoft.public.access.forms
ricky
external usenet poster
 
Posts: 39
Default Default Text for an Empty returned recordset

Thank you Klatuu.

Kind Regards

Ricky

"Klatuu" wrote in message
...
There is one line that needs to be removed.
rst.MoveLast
I don't know how it got there. Copy/Paste can be a dangerous thing.

Post back if you need more help with it.

I also suggest you learn VBA. You can create a workable database without
it, but you will be limited in what you can do. It really isn't that hard

to
do.

"ricky" wrote:

Hi Klatuu

Unfortunately, I have inherited this project from someone who has left

the
company and lets just say VBA is not my forte. Thank you for the code
posting, I'll try it out.

Kind Regards

Ricky

"Klatuu" wrote in message
...
First, rather than have the user enter to parameter value in the

query,
put a
text box on your form and have them enter it there. Then, open the

query
as
a recordset and test the recordcount property. If it returns 0, not

records
are returned.

Change the criteria in your query to reference the control the user

where
the user will enter the criteria

Forms!MyFormName!txtSearchValue

Dim dbf As Database
Dim rst As Recordset
Dim qdf as Querydef
Dim lngRecords As Long

Set dbf = Currentdb
Set qdf = dbf.Querydefs("MyQueryNameHere")
qdf.Parameters(0) = Me.txtSearchValue
Set rst = qdf.OpenRecordset(dbOpenSnapshot, dbReadOnly)
lngRecords = rst.RecordCount
rst.Close
Set rst = Nothing
Set qdf = Nothing
Set dbf = Nothing
If lngRecords 1 Then
MsgBox "No Records Found"
Else
'Do whatever you want with the query
End If
rst.MoveLast

rst.Close
set rst = nothing
set dbf = nothing


"ricky" wrote:

Hi

I have a query executed from a command button. The query prompts

the
user
to supply a variable. If the variable returns no data, how would I

place
some default text to tell the user nothing has been returned.

Kind Regards

Ricky








 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 02:17 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.