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)
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
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.
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
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"
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.