Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

Run-Time error '2424':

Discussion in 'Information Technology' started by Nmidia, Jul 28, 2006.

Tags:
  1. Nmidia

    Nmidia
    Expand Collapse
    Guest

    Hi All,

    I am at the point of despair with this one!

    I have a form which can be opened in either update or addnew mode. the
    form links to the main table. On the form is a subform that contains
    address data. When opened in update mode everything works fine.
    However, when I open the form in addnew record mode, i get "runtime
    error 2424; The expression you entered has a field, control, or propery
    name that .....database can't find."


    This error is occuring on the subform on the following line of code;
    ------------------
    strSQL = "Select * from tbl_Address where [customername] = '" &
    Me.cmbCustomerName & "'"
    -----------------------
    in the following block;


    ---------------------------------------
    Private Sub GetBillingAddress()
    Dim dbDatabase As Database
    Dim rsRecordset As Recordset
    Dim strSQL As String
    Dim Response As Integer
    Dim gContactName As String


    If Not IsNull(Me.cmbCustomerName) Then
    Set dbDatabase = CurrentDb
    strSQL = "Select * from tbl_Address where customername = '" &
    Me.cmbCustomerName & "'"
    Set rsRecordset = dbDatabase.OpenRecordset(strSQL)
    If rsRecordset.RecordCount > 0 Then
    Me.cmbCustomerName = rsRecordset.Fields("customername")
    Me.txtContactName = rsRecordset.Fields("contact")
    Me.txtCUstomerReferenceNumber =
    rsRecordset.Fields("customerref")
    Me.txtBaddline1 = rsRecordset.Fields("baddline1")
    Me.txtBaddline2 = rsRecordset.Fields("baddline2")
    Me.txtBaddline3 = rsRecordset.Fields("baddline3")
    Me.txtBadDline4 = rsRecordset.Fields("baddline4")
    Me.txtBaddline5 = rsRecordset.Fields("baddline5")
    Me.txtPhone = rsRecordset.Fields("phone")
    Me.txtFax = rsRecordset.Fields("fax")
    Me.txtEmail = rsRecordset.Fields("email")
    Me.chkDVDCustomer = rsRecordset.Fields("DVDCustomer")

    End If
    rsRecordset.Close
    Else
    MsgBox "You must enter a Company Name", vbCritical, "Find
    Billing Address"
    End If
    End Sub

    ------------------------------------------------------------------


    this has only recently begun to happen, and i have no idea why. I was
    also able to fix it before by importing a copy of the subform. This
    has also now stopped fixing it.

    The code looks up the address fields from tbl_address to try and
    autofill the fields. If a record exisits in the database with the
    customername the system will autofill the address fields.

    any help is appreciated! if you need more info please ask! Its
    driving me insane!
     
  2. Loading...


  3. Nmidia

    Nmidia
    Expand Collapse
    Guest

    sorry, think I have fixed it! The subform was set to allowadditions -
    no. I guess when it was trying to switch modes it was getting very
    confused!

    lets play spot the monkey coder------yes, its me!


    Nmidia wrote:
    > Hi All,
    >
    > I am at the point of despair with this one!
    >
    > I have a form which can be opened in either update or addnew mode. the
    > form links to the main table. On the form is a subform that contains
    > address data. When opened in update mode everything works fine.
    > However, when I open the form in addnew record mode, i get "runtime
    > error 2424; The expression you entered has a field, control, or propery
    > name that .....database can't find."
    >
    >
    > This error is occuring on the subform on the following line of code;
    > ------------------
    > strSQL = "Select * from tbl_Address where [customername] = '" &
    > Me.cmbCustomerName & "'"
    > -----------------------
    > in the following block;
    >
    >
    > ---------------------------------------
    > Private Sub GetBillingAddress()
    > Dim dbDatabase As Database
    > Dim rsRecordset As Recordset
    > Dim strSQL As String
    > Dim Response As Integer
    > Dim gContactName As String
    >
    >
    > If Not IsNull(Me.cmbCustomerName) Then
    > Set dbDatabase = CurrentDb
    > strSQL = "Select * from tbl_Address where customername = '" &
    > Me.cmbCustomerName & "'"
    > Set rsRecordset = dbDatabase.OpenRecordset(strSQL)
    > If rsRecordset.RecordCount > 0 Then
    > Me.cmbCustomerName = rsRecordset.Fields("customername")
    > Me.txtContactName = rsRecordset.Fields("contact")
    > Me.txtCUstomerReferenceNumber =
    > rsRecordset.Fields("customerref")
    > Me.txtBaddline1 = rsRecordset.Fields("baddline1")
    > Me.txtBaddline2 = rsRecordset.Fields("baddline2")
    > Me.txtBaddline3 = rsRecordset.Fields("baddline3")
    > Me.txtBadDline4 = rsRecordset.Fields("baddline4")
    > Me.txtBaddline5 = rsRecordset.Fields("baddline5")
    > Me.txtPhone = rsRecordset.Fields("phone")
    > Me.txtFax = rsRecordset.Fields("fax")
    > Me.txtEmail = rsRecordset.Fields("email")
    > Me.chkDVDCustomer = rsRecordset.Fields("DVDCustomer")
    >
    > End If
    > rsRecordset.Close
    > Else
    > MsgBox "You must enter a Company Name", vbCritical, "Find
    > Billing Address"
    > End If
    > End Sub
    >
    > ------------------------------------------------------------------
    >
    >
    > this has only recently begun to happen, and i have no idea why. I was
    > also able to fix it before by importing a copy of the subform. This
    > has also now stopped fixing it.
    >
    > The code looks up the address fields from tbl_address to try and
    > autofill the fields. If a record exisits in the database with the
    > customername the system will autofill the address fields.
    >
    > any help is appreciated! if you need more info please ask! Its
    > driving me insane!
     

Share This Page