G
Greg Snidow
Greetings all. I am using Access 2003. On a form I have txthub, and
cboJSCo, among others. The form has as its record source tbljob_info and
these two controls are bound to it. I would like to, after txthub is updated
to look into another table, tblhub_log to see if the
cboJSCO.value/txthub.value combination exists. If it does not exist I want
to insert it into tblhub_log. I am still learning, so I do not know if I can
do this, but this is what I have so far.
************************************************************
Private Sub txthub_AfterUpdate()
On Error GoTo err_txthub_afterupdate
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Me.frmJobInfoSub1.Form.Requery
Dim cn As ADODB.Connection
Dim rsHubLog As ADODB.Recordset
Dim strSQL As String
strSQL = "SELECT co, hub_number FROM tblhub_log WHERE " & _
"co = '" & Form.[cboJSCo] & "' " & _
"AND hub_number = '" & Form.[txthub] & "' ;"
Set rsHubLog = New ADODB.Recordset
Set cn = Application.CurrentProject.Connection
rsHubLog.Open strSQL, cn, adOpenForwardOnly, adLockOptimistic
If strSQL not in rsHubLog Then
insert into tblhub_log(co,hub_number) strSQL
End If
rsHubLog.Close
exit_txthub_afterupdate:
Exit Sub
err_txthub_afterupdate:
MsgBox Err.description
Resume exit_txthub_afterupdate
End Sub
************************************************************
I know the above structure is wrong, mainly because it does not work, but I
was hoping it would convey what I need to do. I am stuck at this point,
thank you for any help.
cboJSCo, among others. The form has as its record source tbljob_info and
these two controls are bound to it. I would like to, after txthub is updated
to look into another table, tblhub_log to see if the
cboJSCO.value/txthub.value combination exists. If it does not exist I want
to insert it into tblhub_log. I am still learning, so I do not know if I can
do this, but this is what I have so far.
************************************************************
Private Sub txthub_AfterUpdate()
On Error GoTo err_txthub_afterupdate
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Me.frmJobInfoSub1.Form.Requery
Dim cn As ADODB.Connection
Dim rsHubLog As ADODB.Recordset
Dim strSQL As String
strSQL = "SELECT co, hub_number FROM tblhub_log WHERE " & _
"co = '" & Form.[cboJSCo] & "' " & _
"AND hub_number = '" & Form.[txthub] & "' ;"
Set rsHubLog = New ADODB.Recordset
Set cn = Application.CurrentProject.Connection
rsHubLog.Open strSQL, cn, adOpenForwardOnly, adLockOptimistic
If strSQL not in rsHubLog Then
insert into tblhub_log(co,hub_number) strSQL
End If
rsHubLog.Close
exit_txthub_afterupdate:
Exit Sub
err_txthub_afterupdate:
MsgBox Err.description
Resume exit_txthub_afterupdate
End Sub
************************************************************
I know the above structure is wrong, mainly because it does not work, but I
was hoping it would convey what I need to do. I am stuck at this point,
thank you for any help.