Help needed ASAP....

Help needed ASAP....

Post by ^MaRkY » Sat, 27 Nov 1999 04:00:00



Heya,

This is my post in this forum and I apologise if I seem stupid or I've
asked a question that's been answered before.

I am working on an Access database for a project-ette and I need to
stop the user from displaying a report if the query behind the report
returns no records. The only problem I've encountered is that
OpenRecordset doesn't seem to like me very much. I've read the MSDN
documentation thousands of times and followed it to the letter and it
refuses to work. My code is...

Dim dbCurrentDatabase As Database
Dim rsRecordSet As RecordSet

Set dbCurrentDatabase = DBEngine.Workspaces(0).Databases(0)
Set rsRecordSet = dbCurrentDatabase.OpenRecordset("Total Sales")
rsRecordSet.MoveLast
if rsRecordSet.RecordCount = -1 Then
   MsgBox "There are no entries to view. Please check your search    
criteria and try again"
   Exit_Subroutine
End If

'Continue with displaying the report...

Exit_Subroutine:
'Cancel displaying the report...

MSDN says that the source parameter (Total Sales - which is a query in
my DB) is compulsory for database.openrecordsets but the others are
optional. However, my error handling catches an error - "Too few
parameters. Expected parameters 2". Why is this?

I've tried using the query.OpenRecordSets and used all four parameters
that the function will accept, but it STILL wants more. Any help would
be appreciated.


Many thanks

Mark

* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!

 
 
 

Help needed ASAP....

Post by Adriano Trevisa » Sat, 27 Nov 1999 04:00:00


Hi Mark,

you have to call OpenRecordset with this syntax:

.OpenRecordset("[Total Sales]")

Look at the brakets!!!!!!!!!!!!!!!!!!! When you have more than one word to
name a query, this is the solution. The same trick as if you have to declare
a multiword field on a table.

Hope this helps
Bye


>Heya,

>This is my post in this forum and I apologise if I seem stupid or I've
>asked a question that's been answered before.

>I am working on an Access database for a project-ette and I need to
>stop the user from displaying a report if the query behind the report
>returns no records. The only problem I've encountered is that
>OpenRecordset doesn't seem to like me very much. I've read the MSDN
>documentation thousands of times and followed it to the letter and it
>refuses to work. My code is...

>Dim dbCurrentDatabase As Database
>Dim rsRecordSet As RecordSet

>Set dbCurrentDatabase = DBEngine.Workspaces(0).Databases(0)
>Set rsRecordSet = dbCurrentDatabase.OpenRecordset("Total Sales")
>rsRecordSet.MoveLast
>if rsRecordSet.RecordCount = -1 Then
>   MsgBox "There are no entries to view. Please check your search
>criteria and try again"
>   Exit_Subroutine
>End If

>'Continue with displaying the report...

>Exit_Subroutine:
>'Cancel displaying the report...

>MSDN says that the source parameter (Total Sales - which is a query in
>my DB) is compulsory for database.openrecordsets but the others are
>optional. However, my error handling catches an error - "Too few
>parameters. Expected parameters 2". Why is this?

>I've tried using the query.OpenRecordSets and used all four parameters
>that the function will accept, but it STILL wants more. Any help would
>be appreciated.


>Many thanks

>Mark

>* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network
*
>The fastest and easiest way to search and participate in Usenet - Free!


 
 
 

Help needed ASAP....

Post by Patrick Garcea » Sat, 27 Nov 1999 04:00:00


Set dbCurrentDatabase = DBEngine.Workspaces(0).Databases(0)
Set rsRecordSet = dbCurrentDatabase.OpenRecordset("Total Sales")
rsRecordSet.MoveLast
if rsRecordSet.RecordCount = -1 Then
   MsgBox "There are no entries to view. Please check your search
criteria and try again"
   Exit_Subroutine
End If

'Continue with displaying the report...

Exit_Subroutine:
'Cancel displaying the report...

Change to this ::::

Set dbCurrentDatabase = DBEngine.Workspaces(0).Databases(0)
Set rsRecordSet = dbCurrentDatabase.OpenRecordset("Total Sales")
if rsRecordSet.RecordCount =0 then
   MsgBox "There are no entries to view. Please check your search criteria
and try again"
   Goto Exit_Subroutine
End If

'Continue with displaying the report...

Exit_Subroutine:
'Cancel displaying the report...

You cannot do a MoveLast or a MoveFirst if your recorset is empty.
And please...., you do NOT use bracket in the openrecordset for the name of
a table.



> Heya,

> This is my post in this forum and I apologise if I seem stupid or I've
> asked a question that's been answered before.

> I am working on an Access database for a project-ette and I need to
> stop the user from displaying a report if the query behind the report
> returns no records. The only problem I've encountered is that
> OpenRecordset doesn't seem to like me very much. I've read the MSDN
> documentation thousands of times and followed it to the letter and it
> refuses to work. My code is...

> Dim dbCurrentDatabase As Database
> Dim rsRecordSet As RecordSet

> Set dbCurrentDatabase = DBEngine.Workspaces(0).Databases(0)
> Set rsRecordSet = dbCurrentDatabase.OpenRecordset("Total Sales")
> rsRecordSet.MoveLast
> if rsRecordSet.RecordCount = -1 Then
>    MsgBox "There are no entries to view. Please check your search
> criteria and try again"
>    Exit_Subroutine
> End If

> 'Continue with displaying the report...

> Exit_Subroutine:
> 'Cancel displaying the report...

> MSDN says that the source parameter (Total Sales - which is a query in
> my DB) is compulsory for database.openrecordsets but the others are
> optional. However, my error handling catches an error - "Too few
> parameters. Expected parameters 2". Why is this?

> I've tried using the query.OpenRecordSets and used all four parameters
> that the function will accept, but it STILL wants more. Any help would
> be appreciated.


> Many thanks

> Mark

> * Sent from RemarQ http://www.remarq.com The Internet's Discussion Network
*
> The fastest and easiest way to search and participate in Usenet - Free!

 
 
 

Help needed ASAP....

Post by ^Mark » Tue, 30 Nov 1999 04:00:00


Thanks guys, for your earlier post. However, the same error still
occurs. I was using a Jet engine but now I've ported it over to an ODBC
type but now, instead of "expecting 2 parameters", it expects FOUR! I
also have to point out that I'm using a parameter query.

Any ideas greatly appreciated and may well be rewarded with an awfully
big cookie.

Many thanks,

Mark


* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!

 
 
 

1. Result Sets easy one I need help need Asap Please guys

I was wondering with a ResultSet I want to display results in a JListBox

lets say my ResultSet returns customer names

the result set returns
kevin
mat
david

IN THE TABLE CALLES CUSTOMER THE FILEDS EXIST
CustomerID,Name,PhoneNumber

then I want to put thouse names in a list box
but what I want to do is when the user clicks in one of those names in the
list box
I want to be able to display the PhoneNumber in a JTextField box
is this possible to do?

2. Where is Patch 8.0.4.3 for Dec Unix 4.0D

3. HELP NEEDED ASAP!

4. US-DC: Washington-Senior Oracle/MS SQL Database Admin

5. Massive Problem - Help needed ASAP

6. array variables in Progress

7. SQLException: login failed- HELP NEEDED ASAP!!

8. Need help with two layouts in one field

9. HELP needed A.S.A.P

10. ******MSDN Libary cd SQL Help need ASAP******

11. Isql query help needed -asap

12. Variables in Stored Procedures - Help needed ASAP