Link to home
Start Free TrialLog in
Avatar of Falke
Falke

asked on

SQL and deleted recordset makes error ....

Hi!

I am using following code:

Dim Datenbank As Database
Dim DatenRecordSet As Recordset
Dim SQLDef As QueryDef
Dim Temp$

Set Datenbank4 = OpenDatabase(App.Path & "\data.mdb")
Temp$ = "SELECT * FROM [Test] "
Set SQLDef = PDatenbank.CreateQueryDef("", Temp$)
Set DatenRecordSet = SQLDef.OpenRecordset()


'*****

if i use it twice at the same time and one of the 2 delete one recordset. How can i know if a recordset is deleted? Is there a easy if then or can i only look for an error (not so good)?

Falke
Avatar of Anthony Perkins
Anthony Perkins
Flag of United States of America image

Please maintain your open questions:
terminate a programm and send vbreturn? Date: 09/23/2001 03:14AM PST  
https://www.experts-exchange.com/questions/20186489/terminate-a-programm-and-send-vbreturn.html

The following should be deleted as no solutions have been contributed:
Resize Taskbar and set the desktop font smaller Date: 04/14/2002 02:27AM PST
https://www.experts-exchange.com/questions/20288984/Resize-Taskbar-and-set-the-desktop-font-smaller.html
DHTMLeditor and helpfile available? Date: 03/20/2002 01:33AM PST
https://www.experts-exchange.com/questions/20279191/DHTMLeditor-and-helpfile-available.html
Embedding Internet Explorer Component into a frame -> how can i retrieve links? Date: 03/11/2002 11:53PM PST
https://www.experts-exchange.com/questions/20275703/Embedding-Internet-Explorer-Component-into-a-frame-how-can-i-retrieve-links.html
mediaplayer and disable hardware-acceleration? Date: 10/26/2001 01:51PM PST
https://www.experts-exchange.com/questions/20218046/mediaplayer-and-disable-hardware-acceleration.html

Thanks,
Anthony
Avatar of Falke
Falke

ASKER

@acperkins
I like your Answers! But thats no answer to my question! To your, how can i delete a question?

Falke
Post a message to that effect in Community Support (https://www.experts-exchange.com/commspt/).

In general, you will find Experts more receptive to your questions when you take the time to maintain them.

Anthony
Avatar of Falke

ASKER

ok done
This should be:

Set Datenbank4 = OpenDatabase(App.Path & "\data.mdb")
Temp$ = "SELECT * FROM [Test] "
Set DatenRecordSet = Datenbank4.OpenRecordset(Temp$)
> How can i know if a recordset is deleted?

Are you mean a recordset object (example DAO.recordset) or a Query object in database? Do you want to check the existence of a Query in database?

regards
Avatar of Falke

ASKER

@ aikimark
you are right .. but that's not the problem
and to correct all it must be:
Set Datenbank = OpenDatabase(App.Path & "\data.mdb")


@ryancys
DAO.Recordset (datenrecordset is a dao.recordset (Dao 3.6)

Falke
Falke ,

My example code does not use a querydef object.  The recordset object is created directly from the database object.  I appologize for the typo.  I had copied code from your question entry.  The Datenbank was spelled Datenbank4 on one of the lines.
Avatar of Falke

ASKER

thanks for the improve ;)

but my problem is, if i use 2 routines at the same time (same SQL) and i delete in one a recordset, in the other i get an error. How can i ask if a recordset has been deleted? I would like to have something like if datenrecordset.isdeleted = True or so.

Falke
do the recordsets have the same name?  If so, they can't be simultaneously addressed by some code.

If DatenRecordSet Is Nothing Then

End If
You cannot delete a recordset.  You can close it and set it to Nothing (In which case you can can conpare to Nothing).  But I do not believe this is what you mean.  I think you are opening two recordsets with the same SQL and one of them is deleting a record.  Your question is then how do you "alert" the other recordset that the record is deleted.

The short answer is you cannot, without requerying the database.  You may want to do one of the following:
1. Check fr this possibility with Error Handling
2. Re-query.
3. Re-think your strategy.

Anthony
Avatar of Falke

ASKER

@acperkins
you are right

i am using it for a login procedure. I give at the first time a "rang order" to the customer, on which queue rang he is. If he terminate before he enter, the datarecordset SQL has been deleted. Every time one has beend entered the other will be informed about the new "rang in the queue", that's the idea.

@acperkins
i do it with an error Handling but i would like to know, if there is a "better way" to know, if this recordset has been deleted.

Falke
>>i do it with an error Handling but i would like to know, if there is a "better way" to know, if this recordset has been deleted.<<

I think that may be your best bet.

Anthony
Avatar of Falke

ASKER

your best bet?
why not use SAME recordset object between tow form(or somewhere you operate data)?
Falke,

After re-reading your question and all the comments, it appears that you ARE NOT deleting the recordset.  Rather, you are rebuilding the recordset when you execute the VB code the second time.

Since you are using the same SQL to build the recordset, this should not cause a problem, other than flicker on bound list, combobox and grid controls.

===========================================
We (both you and us experts) need to step back from the code a moment and understand what you WANT your code to do.  In other words, we experts need to understand the context in which this code is run and why you are running it twice.
Avatar of Falke

ASKER

@aikimark
you are right but i whill show you a partial of my code :

...
Temp2$ = "SELECT * FROM [Login]"
Set SQLDef2 = PDatenbank.CreateQueryDef("", Temp2$)
Set DatenRecordSet2 = SQLDef2.OpenRecordset()
   
Dim bOKNeu As Boolean
While Not DatenRecordSet2.EOF
   Temp$ = "SELECT * FROM [Login]
   Set SQLDef = PDatenbank.CreateQueryDef("", Temp$)
   Set DatenRecordSet = SQLDef.OpenRecordset()
       
        while not datenrecrdset.eof
          'gives the user the actuall queue number
          'if user has gone before entering into theprogramm datenrecordset must be deleted but
            DatenRecordSet.MoveNext
            Wend
        End If

 .....

Falke
ASKER CERTIFIED SOLUTION
Avatar of aikimark
aikimark
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial