A
accesskastle
Ok folks- I’m a first time poster, and I need help, because this problem is
driving me bonkers. I’ve tried DoCmd, SendKeys and requery method (over and
over), reviewing all the previous posts, and all does not seem to be working.
My subform is not refreshing with a button press on the main form. The
mainform’s source is tblWGBRESID, the subform (subform control name
sfrmLINECOVER, sourceobject is sfrmLINECOVERID). Clicking the button is
supposed to cause the addition of whatever is looked up in the third table
(tblLINKLINEID) to the subform. The SQL works; when I open the subform’s
associated table, the data is added to the table. When I close and re-open
the main form, the new data is added to the subform.
But I want the user to see the records in the subform they’ve added after
clicking the command button. I do not want to use DAO. My table setup and
my code for the command button in the main form is posted below. I’m
operating on Access XP, and pretty new to ADO. Please help, and forgive any
breaches in netiquette.
My table setup:
tblLINECOVERID
LINECOVERID-PK
WGBRESID-FK (from tblWGBRESID)
LINKLINEID-FK (from tblLINKLINEID)
tblWGBRESID
WGBRESID-PK
WGBDATE
PEOPLE
HRS
LINKWGBID
tblLINKLINEID
LINKLINEID-PK
LINKWGBID
LINENOID
Private Sub cmdFILLLINES_Click()
Dim CurrConn As New ADODB.Connection
Dim P As String
Dim strSQL As String
Set CurrConn = New ADODB.Connection
P = “my pathwayâ€
With CurrConn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "data source = " & P
.Open
End With
strSQL = "INSERT INTO tblLINECOVERID ( LINKLINEID, WGBRESID )"
strSQL = strSQL & " SELECT tblLINKLINEID.LINKLINEID, "
strSQL = strSQL & [Forms]![frmWGBRESID]![WGBRESID] & " AS WGBRESID "
strSQL = strSQL & "FROM tblLINKLINEID WHERE (((tblLINKLINEID.LINKWGBID) = "
strSQL = strSQL & [Forms]![frmWGBRESID]![LINKWGBID] & "))"
strSQL = strSQL & "GROUP BY tblLINKLINEID.LINKLINEID;"
Debug.Print "strSQL = " & strSQL
CurrConn.Execute strSQL, , adExecuteNoRecords
Debug.Print "Executed strSQL."
CurrConn.Close
Set CurrConn = Nothing
Debug.Print "Set connection to nothing."
Forms("frmWGBRESID")("sfrmLINECOVER").Form.Controls("LINKLINEID").Requery
Debug.Print "Requeried " &
Forms("frmWGBRESID")("sfrmLINECOVER").Form.Controls("LINKLINEID").Name
cmdFILLLINES_Exit:
Exit Sub
cmdFILLLINES_Err:
MsgBox "Error #" & Err.Number & " - " & Err.Description
Resume cmdFILLLINES_Exit
End Sub
driving me bonkers. I’ve tried DoCmd, SendKeys and requery method (over and
over), reviewing all the previous posts, and all does not seem to be working.
My subform is not refreshing with a button press on the main form. The
mainform’s source is tblWGBRESID, the subform (subform control name
sfrmLINECOVER, sourceobject is sfrmLINECOVERID). Clicking the button is
supposed to cause the addition of whatever is looked up in the third table
(tblLINKLINEID) to the subform. The SQL works; when I open the subform’s
associated table, the data is added to the table. When I close and re-open
the main form, the new data is added to the subform.
But I want the user to see the records in the subform they’ve added after
clicking the command button. I do not want to use DAO. My table setup and
my code for the command button in the main form is posted below. I’m
operating on Access XP, and pretty new to ADO. Please help, and forgive any
breaches in netiquette.
My table setup:
tblLINECOVERID
LINECOVERID-PK
WGBRESID-FK (from tblWGBRESID)
LINKLINEID-FK (from tblLINKLINEID)
tblWGBRESID
WGBRESID-PK
WGBDATE
PEOPLE
HRS
LINKWGBID
tblLINKLINEID
LINKLINEID-PK
LINKWGBID
LINENOID
Private Sub cmdFILLLINES_Click()
Dim CurrConn As New ADODB.Connection
Dim P As String
Dim strSQL As String
Set CurrConn = New ADODB.Connection
P = “my pathwayâ€
With CurrConn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "data source = " & P
.Open
End With
strSQL = "INSERT INTO tblLINECOVERID ( LINKLINEID, WGBRESID )"
strSQL = strSQL & " SELECT tblLINKLINEID.LINKLINEID, "
strSQL = strSQL & [Forms]![frmWGBRESID]![WGBRESID] & " AS WGBRESID "
strSQL = strSQL & "FROM tblLINKLINEID WHERE (((tblLINKLINEID.LINKWGBID) = "
strSQL = strSQL & [Forms]![frmWGBRESID]![LINKWGBID] & "))"
strSQL = strSQL & "GROUP BY tblLINKLINEID.LINKLINEID;"
Debug.Print "strSQL = " & strSQL
CurrConn.Execute strSQL, , adExecuteNoRecords
Debug.Print "Executed strSQL."
CurrConn.Close
Set CurrConn = Nothing
Debug.Print "Set connection to nothing."
Forms("frmWGBRESID")("sfrmLINECOVER").Form.Controls("LINKLINEID").Requery
Debug.Print "Requeried " &
Forms("frmWGBRESID")("sfrmLINECOVER").Form.Controls("LINKLINEID").Name
cmdFILLLINES_Exit:
Exit Sub
cmdFILLLINES_Err:
MsgBox "Error #" & Err.Number & " - " & Err.Description
Resume cmdFILLLINES_Exit
End Sub