add record command button in a form

G

Guest

I am fairly new to access. I have a form wherein the record source is a
table. I already have inputted around 110 entries thru the table (datasheet
view) and the form. I have created an "Add Record" command button (using the
wizard) on my form because other users who are not familiar with access will
be using the database. My problem is when I click on the Add Record command
button, an error message, "You cant go to that specified record" appears.
 
J

John Vinson

I am fairly new to access. I have a form wherein the record source is a
table. I already have inputted around 110 entries thru the table (datasheet
view) and the form. I have created an "Add Record" command button (using the
wizard) on my form because other users who are not familiar with access will
be using the database. My problem is when I click on the Add Record command
button, an error message, "You cant go to that specified record" appears.

Can you click on the *> icon in the navigation buttons at the bottom
of the form? Could the form perhaps be based on a non-updateable query
(which would cause this error)?

If not, please post the VBA code in the button's click event.

John W. Vinson[MVP]
 
G

Guest

This is the code on the command button:
Private Sub Add_Record_Click()
On Error GoTo Err_Add_Record_Click


DoCmd.GoToRecord , , acNewRec

Exit_Add_Record_Click:
Exit Sub

Err_Add_Record_Click:
MsgBox Err.Description
Resume Exit_Add_Record_Click

End Sub

When I click on the add record button, I could only add one record and it
"saves" on record 0 instead of the next record. After updating one record,
the error message appears.
 
J

John Vinson

When I click on the add record button, I could only add one record and it
"saves" on record 0 instead of the next record. After updating one record,
the error message appears.

Doublecheck that the Form's AllowAdditions property is True.

John W. Vinson[MVP]
 
G

Guest

Also, I forgot to mention that my form is linked to a table wherein there is
a Lender ID number assigned to each Lender. When I try to add a new record
in the form, the Lender ID field is not "updated" since it is not set to
auto-number. I think that is also creating a problem for me. I know I can't
change it to auto-field anymore. I would appreciate any suggestion. Please
help.
 
J

John Vinson

Also, I forgot to mention that my form is linked to a table wherein there is
a Lender ID number assigned to each Lender. When I try to add a new record
in the form, the Lender ID field is not "updated" since it is not set to
auto-number. I think that is also creating a problem for me. I know I can't
change it to auto-field anymore. I would appreciate any suggestion. Please
help.

Ok, I'm confused. What are the Record Source properties of the
mainform and the subform? What are the Primary Key fields of those
tables? If you are adding a new Lender (on the subform??) and the
lender ID isn't an autonumber how do you want a new LenderID to be
created: manual entry? automated? autonumber? magic <g>? Every record
MUST have a primary key and it must be unique, so it has to come from
somewhere!

John W. Vinson[MVP]
 
G

Guest

Hi John

I don't know where to start. I guess I have to give you a brief description
of my database. It's my first database project and I actually was able to get
a lot of headway by getting help from here (thanks guys!). Anyway, I have
two multi-select list boxes (loan type and property type) and ultimately the
user will make the selection from the two boxes, run the query and show
results on another form (that part is ok). I am trying to make
"enhancements" on my database to make it more user-friendly. These are my
tables:

1) tblLenderMaster (details about the Lender)
Lender ID (number) - primary
Lender Name
Address, etc..

2) tblLoanType (different loan types)
Loan Type ID (number) - primary
Loan Type

3) tblPropType (different property types)
Prop Type ID (number) - primary
Property Type

To cross reference:

4) tblLenderLoanType
Lender Loan ID (number) - primary
Lender ID
Loan Type ID

5) tblLenderPropType
Lender Prop ID (number) - primary
Lender ID
Prop Type ID

I created a form (frmLenders), the record source of which is
tblLenderMaster. I have already populated my database. Here are my
questions/problems:

1) I added a Add Record command button on the frmLenders. When I click the
button, only one record (the next record) is updated then when you try to
update the next record in line, the error message, "You can't go to the
specified record" appears. Then when I try to close the form this error
message appears, "Index or primary key cannot contain a null value". My
guess is that my form is populating all the other fields except for Lender ID
(since it is not an auto-number field).

2) Also, will it be possible to add combo boxes or maybe check boxes on my
frmLenders so that when another user adds a new record, he can easily update
under which Loan Type/s and Property Type/s the Lender belongs to? If ever,
will that be easy to program?

I really appreciate all your help.
 

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