|
-
Feb 7th, 2005, 02:48 PM
#1
Thread Starter
Addicted Member
[resolved] Requery
Hello ppl
I want the user to always print record with changes that he just made, but I am running into problems.
I have a simple form that reads from and Access fie (ADO, VB 6).
I have a print button that connects to a data environment and prints the contect of prestent recordset (by filtering adodc1).
Problem is:
Sometimes user make some changes on the screen and wants to print right away. My print will not be updated.
I tried adding :
EDDU.rsTBLNames.Requery
but I am getting error message saying:
run time error 3704
Operation is not allowed when the object is closed.
and the degugger highlights the code line mentioned above.
Any suggestions as how to solve this problem?
Last edited by SaharaWizard; Feb 9th, 2005 at 01:54 PM.
Don't let your schooling get in the way of your education.
-
Feb 7th, 2005, 03:04 PM
#2
Frenzied Member
Re: Requery
Is your recordset being closed before you call the requery?
Tengo mas preguntas que contestas
-
Feb 7th, 2005, 05:41 PM
#3
Thread Starter
Addicted Member
Record closing
Since I still have not found a quick way to bound a lot of text boxes and other stuff by code, I am using databound controls and ADODC control.
SO I do not manually (by code) open or close recordset. HOwever becasue of type of error I guess after data has been read by the form it closes (or does it?!)
Please keep in mind that I am using ODBC (DNSless connection).
Last edited by SaharaWizard; Feb 7th, 2005 at 05:59 PM.
Don't let your schooling get in the way of your education.
-
Feb 8th, 2005, 12:05 PM
#4
Frenzied Member
Re: Requery
I don't use bound controls anyway.
What is EDDU? Is that closed?
Sometimes when you're debugging, the actual cause of the error may be a line or two above the one highlighted, like when you try a rs.MoveFirst on an empty recordset. It's true you can't do that, but the reason is you have no records to .MoveFirst to.
Tengo mas preguntas que contestas
-
Feb 8th, 2005, 01:39 PM
#5
Thread Starter
Addicted Member
Re: Requery
I am not crazy about bound controls myself, but sometimes they save time for small tasks (such as just making a list to pick an item from).
Let me change my question:
Can a DNSless connections (ODBC) use requery?
If you were not using bound, how would you get the data into the text box. What I do is this:
txtIdNumber.text = rs.fields("Id").value
Is this the best way? It takes a lot of code for edits and updates and saves though.
Don't let your schooling get in the way of your education.
-
Feb 8th, 2005, 02:28 PM
#6
Frenzied Member
Re: Requery
I don't know the answer to your ODBC question, but although it takes more code to write and execute SQL statements, you have a lot more control. It's not that much more code. You can write generic functions to do updates, adds, etc, and then just pass in a tablename & sql string, for example, to save from writing the same code over and over. You can write classes to do the same thing, if you know enough yet to write those.
Tengo mas preguntas que contestas
-
Feb 8th, 2005, 02:35 PM
#7
Re: Requery
We name our textboxes (actually we use labels that look like textboxes) to match "exactly" the column names of the returned recordset. That way we have a generic LOADINQUIRE function to fill any form with a recordset.
This is our own version of home-grown binding.
We use labels because we like the trick of floating a textbox or combobox onto the label that is clicked so that we have tons less event logic to worry about.
We also use FLEXGRID extensively. If the RECORDSET's first column name starts with "~grdNAME/COLUMN NAME" then we find a flex grid called "NAME" and dump the recordset into that flexgrid. We pull the column names for the flex grid right from the recordset.
We turn this same concept around and use if for UPDATE STORED PROCEDURES.
But, to comment on your first statement - we do not ALLOW PRINT of UNSAVED data - we actually FORCE A SAVE when a PRINT button is hit. We never want a person walking away with a printout of data that is simply sitting in the client side and might never make it to the server database.
-
Feb 9th, 2005, 05:06 AM
#8
Re: Requery
Like the others who have posted, I dont work with Bound controls. I would recommend something along the lines of what salvelinus posted (I use similar methods myself).
Anyway, hopefully this will answer your question:
As the data in the textboxes has changed, the recordset is probably in Edit mode (you can check this using the EDDU.rsTBLNames.Editmode, adEditNone means the current record is not being edited).
If you want to save before you print, you will need to Update the recordset to see the changes, eg:
VB Code:
If EDDU.rsTBLNames.Editmode <> adEditNone Then
EDDU.rsTBLNames.Update
End If
'your printing code here...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|