J
JKarchner
I found this code online and modified to work with my database. However i
get an error saying: "Can't find project or library" on the first line with
DAO in it. My code is below, can anyone help me?
Private Sub Form_AfterInsert()
If Me.SupplyPartCategory = "Window" Then
Dim SQL As String
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim strQuote As String
strQuote = Chr$(34)
Set db = CurrentDb()
SQL = "SELECT Model_ID, SupplyPart_ID" _
& "FROM qryWWindowsXREFModels" _
& "WHERE qryWWindowsXREFModels.Model_ID =" _
& strQuote & Me.Model_ID & strQuote _
& "AND qryWWindowsXREFModels.SupplyPart_ID =" _
& strQuote & Me.SupplyPart_ID & strQuote & ";"
Set rst = db.OpenRecordSet(SQL, dbOpenDynset)
If rst.RecordCount = 0 Then
SQL = "INSERT INTO qryWWindowsXREFModels (Model_ID, SupplyPart_ID)
VALUES (" & Me.Model_ID & ", " & Me.SupplyPart_ID & ")"
DoCmd.RunSQL SQL
Me.Parent.[subFrmWQryWindows(New)].Form.Requery
End If
End If
End Sub
Thank you for any help you can provide.
get an error saying: "Can't find project or library" on the first line with
DAO in it. My code is below, can anyone help me?
Private Sub Form_AfterInsert()
If Me.SupplyPartCategory = "Window" Then
Dim SQL As String
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim strQuote As String
strQuote = Chr$(34)
Set db = CurrentDb()
SQL = "SELECT Model_ID, SupplyPart_ID" _
& "FROM qryWWindowsXREFModels" _
& "WHERE qryWWindowsXREFModels.Model_ID =" _
& strQuote & Me.Model_ID & strQuote _
& "AND qryWWindowsXREFModels.SupplyPart_ID =" _
& strQuote & Me.SupplyPart_ID & strQuote & ";"
Set rst = db.OpenRecordSet(SQL, dbOpenDynset)
If rst.RecordCount = 0 Then
SQL = "INSERT INTO qryWWindowsXREFModels (Model_ID, SupplyPart_ID)
VALUES (" & Me.Model_ID & ", " & Me.SupplyPart_ID & ")"
DoCmd.RunSQL SQL
Me.Parent.[subFrmWQryWindows(New)].Form.Requery
End If
End If
End Sub
Thank you for any help you can provide.