the new record, clicking on the star at the bottom bar

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to write some codes to deal with the star at the bottom of the table
(with the form is frontend). By clicking on this star, one will go to a new
record and on the form, the Id value will be automatically popped up along
with other empty fields for data entry. Can you show me how to do that?
Thank you, tim
 
Tim,

No code is necessary. as long as you meet the following conditions:

- The form's RecordSource property is set to the name of your table
- Your ID field is the AutoNumber type
- The form's AllowEdits and AllowAdditions properties are set to Yes

All of which would be the case if you create the form with the wizard.

Sprinks
 
Hi, Tim.
Can you show me how to do that?

Sure. One needs the following settings:

1.) The form's Record Source Property is a query name, table name, or valid
SQL statement. A query name is preferable in most cases, as it is the most
flexible when the form's properties need to be manipulated.

2.) The form's Allow Edits and Allow Additions Properties are both set to
"Yes."

3.) Either the ID field is an AutoNumber field or a programmatically
produced value whenever a new record is created.

4.) To create a new record with VBA code for the bound form, try the
following code:

DoCmd.GoToRecord , , acNewRec

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.
 
Hi,
Thank you for your help. Sorry about the ID field. Actually, it is a field
with the value of StudenID that has 5 characters in length, i.e., 21032. I
can not use AutoNum for this field. How can I code this programmatically?
Thank you,
tim
 
Hi, Tim.
Thank you for your help. Sorry about the ID field. Actually, it is a field
with the value of StudenID that has 5 characters in length, i.e., 21032. I
can not use AutoNum for this field. How can I code this programmatically?

Well, it depends upon how you want this five character value designed. Is
it to be incremented by one each time a new record is created? Does it
require leading zeros? Is there a floor and ceiling for this number? Will
it ever have non-digits? Et cetera.

A very simple method of incrementing a field by one is to use the DMax( )
function to find the highest number in a field and add one to that number.
If you need to format that value with leading zeros, then try:

Me!txtStudentID.Value = Format((Nz(DMax("StudenID", "tblStudents"), 0) +
1), "00000")

.... where txtStudentID is the name of the text box displaying the StudenID
field, and tblStudents is the name of the table where the StudenID field is
located.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.
 
Back
Top