Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding New Records

Status
Not open for further replies.

wreded

Technical User
Dec 18, 2001
119
US
i've searched the FAQs and read several of the posts in the forum and still come up with a blank for my question.
i have a one field form...
On the form i have two labels to show users they are either editing or adding records.
OnCurrent:
Code:
    Me.AllowAdditions = False
    Me.AllowEdits = False
    Me.lblEditing.Visible = False
    Me.lblAdding.Visible = False
    Me.btnGoNext.SetFocus

Editing works correctly. Adding does not.
btnAddRcd:
Code:
On Error GoTo Err_btnAddRcd_Click
    Me.lblAdding.Visible = Not Me.lblAdding.Visible
    'Me.AllowAdditions = True
    Me.AllowEdits = True
    Me.DataEntry = True
    'DoCmd.RunCommand acCmdSaveRecord
    DoCmd.GoToRecord , , acNewRec
Exit_btnAddRcd_Click:
    Exit Sub
Err_btnAddRcd_Click:
    MsgBox Err.Description
    Resume Exit_btnAddRcd_Click
As You can see i've tried resetting "AllowAdditions" and saving the previous record but i still get "You can't go to the specified record."
This table is a lookup table to allow easy lookups to frequently accessed data and i could allow direct adding and editing but prefer not to so that the whole application acts the same throughout.
Any ideas?
Thanks,
Dave
 
Code:
On Error GoTo Err_btnAddRcd_Click
    Me.lblAdding.Visible = Not Me.lblAdding.Visible
    'Me.AllowAdditions = True
    Me.AllowEdits = True
    [b]Me.DataEntry = True[/b]
    'DoCmd.RunCommand acCmdSaveRecord
    [b]DoCmd.GoToRecord , , acNewRec[/b]
Exit_btnAddRcd_Click:
    Exit Sub
Err_btnAddRcd_Click:
    MsgBox Err.Description
    Resume Exit_btnAddRcd_Click

I think either of the bold lines not required


________________________________________________________
Zameer Abdulla
Help to find Missing people
Sharp acids corrode their own containers.
 
You're right, i don't need those 2 lines. However, when focus shifts from the "btnAddRcd" to the data entry field the data entry field just disappears and i am unable to add new records.
This is puzzling to me. In fact, the btnAddRcd acts just like the btnEditRcd allowing me to make CHANGES to the data but NOT to allow adding new records.
Code:
Private Sub btnEditRcd_Click()
    Me.AllowEdits = Not Me.AllowEdits
    Me.lblEditing.Visible = Not Me.lblEditing.Visible
    If Me.lblEditing.Visible = True Then
        Me.DutyTitles.SetFocus
    End If
End Sub
i turn off the standard navigation buttons and create my own so maybe that's a problem too.
Thanks,
Dave
 
I said one of those lines not required not to remove both.

Also try setting
Me.AllowAdditions = True

________________________________________________________
Zameer Abdulla
Help to find Missing people
Sharp acids corrode their own containers.
 
Oops! My mistake...
Tried remarking out one line at a time and still get the same error either way. i may have to rethink how i'm doing this particular form.
Dave
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top