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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Indicating the number of records save.

Status
Not open for further replies.

ChoonHong

Programmer
Jul 22, 2003
28
SG
Is there a way that a save button can indicate how many records are save in the current form?

If there is can anyone please give me some advice thanks.
 
Needs more explanation:
what is the form
does it have a data source
what does it do etc
 
Hmm the form is just use to save records and i wanna the form to act in a way that when i finish the first record, i would click the next record to fill in another particulars.

After which when i press the Save record button, it would prompt out a message box indicating that "2 records have been save".

I have create a save record button but it does not indicate how many records have been save. Is there a way to count the number of records that is save?
 
you could create a label (Visible = No) on the form that takes the number of records when you first open the form (event Form_OnLoad label.Caption = NoOfRecords) then SaveButton_OnClick msgBox "Number of records saved = " & CurrentNoOfRecords - Cint(Label.Caption)

chirpy
 
Does this statement

(event Form_OnLoad label.Caption = NoOfRecords)

automatically record down the number of records that is save? I am a novince in Access so i am not sure what do some of the codes meant.
 
Have you linked the form to a query or a table?
If so, when you change the record the information is saved automatically.
So I would create a label (not visible) in the form not linked to a field in the table or the query and then if you go into properties of the form (mode creation), Event->OnLoad->generateCode you should find yourself in the sub
There are probably better ways if doing this but I haven't much time so....
FormName_OnLoad ()
Me!LabelName.caption = "0"
end sub

Then if you create an event AfterInsert again in your form that would give

sub Form_AfterInsert()
Me!LabelName.caption = cStr(cint(Me!LabelName.caption) + 1)
msgBox Me!LabelName.caption & " records saved"
end sub

*- Stars always welcome -*
 
Yah i have link my form to my Particulars table. I have also done what u have ask, creating a label to do the counts. Now i have a coding which act in this way:

Private Sub Form_Load()
'Maximize the form window on startup.

DoCmd.Maximize
DoCmd.GoToRecord , , acNewRec

Me!lblCount.Caption = "0"

End Sub

Private Sub Form_AfterInsert()
Me!lblCount.Caption = CStr(CInt(Me!lblCount.Caption) + 1)
MsgBox Me!lblCount.Caption & " records saved"
End Sub

There is a problem in this code because when i press the save record button, a msg box prompts out and say that i cannot go to the specific record. Under the status bar it says "calculating".

Can you please tell me if the way that i coded is correct? Sorry for disturbing your concertration.
 
OMG looks like my file been courruptted... now even if i cancel the previous codings i can't save my records...
 
This is the code on my add button:


Private Sub btnAdd_Click()
On Error GoTo Err_btnAdd_Click


Dim stFirst As String
Dim stLast As String
Dim stPhone As String
Dim stHp As String
Dim stFax As String
Dim stMail As String
Dim stLocation As String
Dim stDivision As String
Dim stTitles As String

'Store previous data.
stFirst = Me.txtFirst
stLast = Me.txtLast
stPhone = Me.txtPhone
stHp = Me.txtHp
stFax = Me.txtFax
stMail = Me.txtMail
stLocation = Me.txtLocation
stDivision = Me.txtDivision
stTitles = Me.txtTitles

'Copy data to new record.

Me.txtFirst = stFirst
Me.txtLast = stLast
Me.txtPhone = stPhone
Me.txtHp = stHp
Me.txtFax = stFax
Me.txtMail = stMail
Me.txtLocation = stLocation
Me.txtDivision = stDivision
Me.txtTitles = stTitles
Me.txtFirst.SetFocus


DoCmd.GoToRecord , , acNewRec

MsgBox "Record Save"
DoCmd.GoToRecord , , acFirst
DoCmd.GoToRecord , , acNewRec

Exit_btnAdd_Click:
Exit Sub

Err_btnAdd_Click:
MsgBox Err.Description
Resume Exit_btnAdd_Click
End Sub

My program can work well again~
 
seems to be a lot of effort for nothing

If you attach the form to the table / query then after you have entered all the information into the form the record will save itself!

Then you'll not need a button or any of the code above.

You have the first event : OnLoad that has the code Me!lblCount.Caption = "0"

then the second event : OnInsertion with ()
Me!LblCount.caption = cStr(cint(Me!LblCount.caption) + 1)
msgBox Me!LabelName.caption & " records saved"

Voila

Chirpy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top