Code is Wrong?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • DS

    #1

    Code is Wrong?

    What in this code is stopping me from adding new records?

    Private Sub ListProd_Click( )
    On Error GoTo GotError
    DoCmd.GoToContr ol "[Sales Details]"
    Me![Sales Details].Form.AllowAddi tions = True
    DoCmd.GoToRecor d , , acNewRec
    Me![Sales Details]![ProductID] = Me.ListProd.Col umn(0)
    Me![Sales Details].Form.Dirty = False
    Me![Sales Details].Form.AllowAddi tions = True
    'DoCmd.OpenForm ("Modifiers" )

    ExitSub:
    Exit Sub

    GotError:
    Select Case Err.Number
    Case 2501
    Resume ExitSub
    Case Else
    MsgBox Err.Number & vbCrLf & Err.Description & vbCrLf & "Why Not"
    Resume ExitSub
    End Select
    End Sub

    Thanks
    DS
  • MGFoster

    #2
    Re: Code is Wrong?

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    You need to set focus on the subform control before using the GoToRecord
    command.

    Me![Sales Details].Form.AllowAddi tions = True
    Me![Sales Details].SetFocus
    ' Sometimes you need to set focus on a control in the subform
    'Me![Sales Details]!ControlName.Se tFocus
    DoCmd.GoToRecor d , , acNewRec

    --
    MGFoster:::mgf0 0 <at> earthlink <decimal-point> net
    Oakland, CA (USA)

    -----BEGIN PGP SIGNATURE-----
    Version: PGP for Personal Privacy 5.0
    Charset: noconv

    iQA/AwUBQlV+9IechKq OuFEgEQJW5wCfej NI4DMct/B9K4u2N3wxUEZ+d V4Ani/7
    HxO80gTjAgQGhZ+ 5n42zZeEo
    =4Gyp
    -----END PGP SIGNATURE-----


    DS wrote:[color=blue]
    > What in this code is stopping me from adding new records?
    >
    > Private Sub ListProd_Click( )
    > On Error GoTo GotError
    > DoCmd.GoToContr ol "[Sales Details]"
    > Me![Sales Details].Form.AllowAddi tions = True
    > DoCmd.GoToRecor d , , acNewRec
    > Me![Sales Details]![ProductID] = Me.ListProd.Col umn(0)
    > Me![Sales Details].Form.Dirty = False
    > Me![Sales Details].Form.AllowAddi tions = True
    > 'DoCmd.OpenForm ("Modifiers" )
    >
    > ExitSub:
    > Exit Sub
    >
    > GotError:
    > Select Case Err.Number
    > Case 2501
    > Resume ExitSub
    > Case Else
    > MsgBox Err.Number & vbCrLf & Err.Description & vbCrLf & "Why Not"
    > Resume ExitSub
    > End Select
    > End Sub[/color]

    Comment

    Working...