Results 1 to 2 of 2
  1. #1
    chuman vishal is offline Novice
    Windows XP Access 2007
    Join Date
    Feb 2013
    Posts
    2

    compile error ????

    iam getting this error iam completely stuck plzz help if u can here is my codes and there is an attach image plzzz help!!!


    here is the code for saving a data:

    Private Sub cmdsave_Click()
    On Error GoTo errhandle 'to handle any other unforseen errors
    'To validate the usser input
    If txtcus.Text = "" Then
    MsgBox "Please enter a CustomerID", vbCritical, "Error"
    txtcus.SetFocus
    Exit Sub 'That is jump to Exit sub statement'
    End If

    If txtnme.Text = "" Then
    MsgBox "Please enter a Name", vbCritical, "Error"
    txtnme.SetFocus
    Exit Sub
    End If

    If txtsnme.Text = "" Then
    MsgBox "Please enter a Surname", vbCritical, "Error"
    txtsnme.SetFocus
    Exit Sub
    End If

    If txtadd.Text = "" Then
    MsgBox "Please enter an Address", vbCritical, "Error"
    txtadd.SetFocus
    Exit Sub
    End If

    If txtage.Text = "" Then
    MsgBox "Please enter the Age", vbCritical, "Error"
    txtage.SetFocus
    Exit Sub
    End If

    If txtpnum.Text = "" Then
    MsgBox "Please enter a Telephone number", vbCritical, "Error"
    txtpnum.SetFocus
    Exit Sub
    End If

    If operation = "ADD" Then
    response = MsgBox("Save Record?", vbQuestion + vbYesNo)
    If response = vbYes Then
    MousePointer = vbHourglass
    AdoCustomer.Recordset.MoveLast
    AdoCustomer.Recordset.AddNew Array("CustomerID", "Name", "Surname", "Address", "Age", "TelephoneNumber") 'Array(txtcus.Text,txtnme.Text,txtsnme.Text,txtadd .Text,val(textage.Text),txtpnum.Text))
    AdoCustomer.Refresh
    MousePointer = vbDefault
    MsgBox "New Record Added"
    Else
    MsgBox "Record Not Added"

    End If

    'Elself operation = "MODIFY" then

    response = MsgBox("Update Record?", vbQuestion + vbYesNo)
    If response = vbYes Then
    MousePointer = vbHourglass
    'look at record in AdoCustomer
    AdoCustomer.Recordset.MoveFirst


    StrSearch = "CustomerID ='" + Trim(txtcus.Text) + "'"
    AdoCustomer.Recordset.Find (StrSearch)
    AdoCusomer.Recordset.Update Array("CustomerID", "Name", "Surname", "Address", "Age", "TelephoneNumber") 'Array(txtcus.Text,txtnme.Text,txtsnme.Text,txtadd .Text,val(textage.Text),txtpnum.Text))
    AdoCustomer.Refresh
    MousePointer = vbDefault
    MsgBox ("Record Updated")
    Else
    MsgBox ("Record Not Updated")
    End If

    'call re-initialise screen procedure
    reinitialise_screen
    Exit Sub 'Exit Sub Statement.Upon ant error program execution will jump to this point
    'the errhandle will handle any other errors that may occur.
    'it prevents the usual VB error messages from being displyed.
    errhandle:
    MousePointer = vbDefault
    MsgBox Err.Description, vbCritical, "Cannot save..."
    Err.Clear
    Attached Files Attached Files

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    I can't look at the attachment right now, but for starters, you don't want to use the .Text property, as it requires focus. Use .Value instead.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Compile Error: Syntax Error in DoCmd.RunSQL Statement
    By Evilferret in forum Programming
    Replies: 1
    Last Post: 08-27-2012, 12:32 PM
  2. Replies: 2
    Last Post: 06-23-2012, 11:59 PM
  3. Replies: 7
    Last Post: 06-08-2012, 09:55 PM
  4. Replies: 6
    Last Post: 09-28-2011, 09:20 PM
  5. compile error
    By darklite in forum Access
    Replies: 6
    Last Post: 08-31-2010, 04:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums