• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 529
  • Last Modified:

DBGRID refresh

I am using vb6.0 and access97. i have 2 tables. A and B. I am trying to make a purchase order program that when you hit the button new it assigns a number to the next order. Now when i run this code i get a refresh error. The access table i connect to has a count field. But i don't know why i get a refresh error.I want the dbgrid to be the details of different orders but with the same assigned order number

Private sub datproducts_reposition()
 dim strsql as string
if datproducts.recordset.recordcount = 0 then
exit sub
end if
strsql = "select * from [order details] where productid = " & datproducts.recordset.fields("productid")
datorderdetails.recordsource = strsql
datorderdetails.refresh
dbgorderdetails.columns("productid").defaultvalue = datproducts.recordset.fields("productid")
end sub
0
jbird090897
Asked:
jbird090897
  • 2
1 Solution
 
vettrangerCommented:
Here's some code that I took directly from a working project that does the same thing. I've modified it to use your naming details. Note that I've taken the space out of your OrderDetails table ... its bad practice to included imbedded spaces in either table or field names.

Temp$ = datProducts.Recordset!ProductID
q$ = "Select * from OrderDetails where ProductID = " & Chr(34) & Temp$ & Chr(34)
'if ProductID is a numeric field, then
'use the following line
'q$ = "Select * from OrderDetails where ProductID = " Temp$

datOrderDetails.RecordSource = q$
datOrderDetails.Refresh
dbgOrderDetails.Refresh

If this code doesn't work, please post the exact error number and message you are getting, as well as the line program execution is stopping on.
0
 
vettrangerCommented:
The commented select statement should be :

'q$ = "Select * from OrderDetails where ProductID = " & Temp$

Sorry about that, I deleted one to many ampersands!
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now