I use VB6 on WinXP - Using Access97 mdb.
SEE SCREENSHOT BELOW!
Here is what I have run into. I have learned ADO (code only - no controls) fairly quickly, but I have run into a snag...
1) I open a db connection-recordset on Form_Load
2) It fills in a datagrid
3) All my Test buttons (plain 3D grey ones) all work fine.
GREAT UP TO NOW!
THEN I ADDED A FILTER! (not so good)
On the right "LEDGER TOTALS" I filter totals from the db table (not the datagrid) to get my amounts... works fine!
BUT...
When I try to Add a record I get the ADO error.
Here is the code for the filter...
VB Code:
Dim Inc As Integer, IncBal As Currency IncBal = "0.00" DoEvents Set adoPrimaryRS = New Recordset adoPrimaryRS.Open "SELECT * FROM Register", db adoPrimaryRS.Filter = "Type = 'Income'" For Inc = 1 To adoPrimaryRS.RecordCount adoPrimaryRS.AbsolutePosition = Inc IncBal = IncBal + adoPrimaryRS.Fields("Credit").Value Next Inc lbIncome.Caption = Format(IncBal, "0.00") adoPrimaryRS.Filter = adFilterNone
I have 3 of these block in my procedure. The reason I know this is the problem is because I disabled the procedure and I could Add a record fine.
Then to prove my point I enabled the procedure again. But before clicking the Add button, I clicked my Refresh button... WORKS FINE!
This is what I need. I need a way to refresh the main data connection from with in the above procedure.
I can not use the "Refresh" button because it will undo any sorts, filters, finds and column widths that were edited.
So basically I have to give my data connection back to my app on the main form.
Any Ideas?
Thanks
The Screenshot below has been made smaller to save size. Grey buttons on top are for testing purposes.




Reply With Quote