I have something weird happening.
I have a class that has a statement like so (shortened for this purpose)
Private Sub Class_Initialize()
Dim sSQL As String
Dim db As Connection
Set db = New Connection
db.CursorLocation = adUseClient
db.Open "PROVIDER=MSDataShape;Data PROVIDER=MSDASQL;dsn=" & DSN & ";uid=" & USERID & ";pwd=" & PASSWORD & ";"
Set adoPrimaryRS = New Recordset
sSQL = "SHAPE {select Company_Code,Product_Code,Insertion_Order_Number, from Order "
If frmBuys.txtfields(18).Text <> "" Then
sSQL = sSQL & " where Product_Code = '" & Trim (frmOrder.txtfields(18).Text) & "' "
End If
sSQL = sSQL & " where Product_Code = 'CHIC'"
sSQL = sSQL & "} AS ParentCMD APPEND "
sSQL = sSQL & "({select Insertion_Order_Number, Run_Date etc.... from OrderDetail Order by Run_Date } AS ChildCMD RELATE Insertion_Order_Number TO Insertion_Order_Number) AS ChildCMD"
adoPrimaryRS.Open sSQL, db, adOpenStatic, adLockOptimistic
DataMembers.Add "Primary"
DataMembers.Add "Secondary"
End Sub
Now in my main form I took this logic out of Form_Load and did the following
If vbKeyReturn = KeyAscii Then
Set PrimaryCLS = New clsBuys
Dim oText As TextBox
'Bind the text boxes to the data provider
For Each oText In Me.txtfields
oText.DataMember = "Primary"
Set oText.DataSource = PrimaryCLS
Next
grdDataGrid.DataMember = "Secondary"
Set grdDataGrid.DataSource = PrimaryCLS
Call LoadGrid
End If
So basically, I want the user to type something in the product_code field and bring back only those records that match.
Strange thing is:
1) First time I hit enter, the value doesn't seem to pass to the class. But on 2nd attempt it works.
2) First time I hit enter, it does actually retrieve the FULL recordset(disregards the select) and repaints a blank form over top. (if I close the form after the first enter, there is another instance of the form with the full recordset).
I hope this makes sense....Any ideas on what is going on???
I have a class that has a statement like so (shortened for this purpose)
Private Sub Class_Initialize()
Dim sSQL As String
Dim db As Connection
Set db = New Connection
db.CursorLocation = adUseClient
db.Open "PROVIDER=MSDataShape;Data PROVIDER=MSDASQL;dsn=" & DSN & ";uid=" & USERID & ";pwd=" & PASSWORD & ";"
Set adoPrimaryRS = New Recordset
sSQL = "SHAPE {select Company_Code,Product_Code,Insertion_Order_Number, from Order "
If frmBuys.txtfields(18).Text <> "" Then
sSQL = sSQL & " where Product_Code = '" & Trim (frmOrder.txtfields(18).Text) & "' "
End If
sSQL = sSQL & " where Product_Code = 'CHIC'"
sSQL = sSQL & "} AS ParentCMD APPEND "
sSQL = sSQL & "({select Insertion_Order_Number, Run_Date etc.... from OrderDetail Order by Run_Date } AS ChildCMD RELATE Insertion_Order_Number TO Insertion_Order_Number) AS ChildCMD"
adoPrimaryRS.Open sSQL, db, adOpenStatic, adLockOptimistic
DataMembers.Add "Primary"
DataMembers.Add "Secondary"
End Sub
Now in my main form I took this logic out of Form_Load and did the following
If vbKeyReturn = KeyAscii Then
Set PrimaryCLS = New clsBuys
Dim oText As TextBox
'Bind the text boxes to the data provider
For Each oText In Me.txtfields
oText.DataMember = "Primary"
Set oText.DataSource = PrimaryCLS
Next
grdDataGrid.DataMember = "Secondary"
Set grdDataGrid.DataSource = PrimaryCLS
Call LoadGrid
End If
So basically, I want the user to type something in the product_code field and bring back only those records that match.
Strange thing is:
1) First time I hit enter, the value doesn't seem to pass to the class. But on 2nd attempt it works.
2) First time I hit enter, it does actually retrieve the FULL recordset(disregards the select) and repaints a blank form over top. (if I close the form after the first enter, there is another instance of the form with the full recordset).
I hope this makes sense....Any ideas on what is going on???