Run time 2465

K

Klam

I want to insert the data from a table to a form and the error message come
us as
Run time error 2465
Main switchboard cannot finmd the field "!" refered to yo9ur expression

Following is the expression and the error is
[Form_Discount Subform].Repaint

Don't know what's wrong and how to fix it



Private Sub btndiscount_Click()

Dim intOrderID, Discount As Variant, X As Integer, rs As Recordset

Dim sSQL As String
Dim db As Database
'Dim rs As DAO.Recordset



'Dim intOrderID As Integer, Coverage As Variant, X As Integer, rs As Recordset

SaveRecord_Click

If IsNull(OrderID) Then
Exit Sub
ElseIf IsNull(SupplierID) Then
MsgBox "Please select insurance company first.", vbCritical
Exit Sub
Else
intOrderID = OrderID
'CurrentDb.QueryDefs.Delete "getCoverage"
'CurrentDb.CreateQueryDef "getCoverage", "SELECT Coverages.CoverageID,
Coverages.CoverageName FROM Coverages INNER JOIN tblCombination ON
Coverages.CoverageID=tblCombination.CoverageID WHERE
tblCombination.SupplierID=" & Current_Insurer & " AND
tblCombination.PolFormID=" & PolFormID & " ORDER BY tblCombination.Order"

sSQL = "SELECT DiscountID, DiscountType FROM Discount WHERE
SupplierID=" & Current_Insurer & ""


Set rs = CurrentDb.OpenRecordset(sSQL)


If rs.BOF And rs.EOF Then
MsgBox "There is no discount under this insurer!", vbInformation
Exit Sub
Else
Discount = rs.GetRows(rs.RecordCount)
Set rs = Nothing

For X = 0 To UBound(Discount, 2)
'CurrentDb.QueryDefs.Delete "InsertOrderDetails"
'CurrentDb.CreateQueryDef "InsertOrderDetails", "INSERT INTO
[Order Details] VALUES (" & intOrderID & ", " & Coverage(0, x) & ", '" &
Coverage(1, x) & "', '0', '0', 0)"

'CurrentDb.Execute "INSERT INTO [Discount Details] VALUES (" &
intOrderID & ", " & Discount(0, X) & ", '" & Discount(1, X) & "','" &
Discount(2, X) & "', '" & Discount(3, X) & "'," & X + 1 & ")"

CurrentDb.Execute "INSERT INTO [Discount Details] VALUES (" &
intOrderID & ", " & Discount(0, X) & ", '" & Discount(1, X) & "','0')"


Next

'[Form_Orders Subform].CoverageID.RowSource = "getCoverage"
'[Form_Orders Subform].CoverageID.Requery


[Discount Subform].Requery
[Form_Discount Subform].Repaint
End If

End If


End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top