Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old November 13th, 2005, 11:04 AM
simonmarkjones@gmail.com
Guest
 
Posts: n/a
Default When shall i call my function?

Hi im a newbie to Access only started programing VBA in Access today.

I've got a function that increments a number. I want to call this ONLY
when the complete record has been filled out.

Using the navigation buttons access creates a new record when the form
is filled out. So i want to call the function when it does this.

Cheers

  #2  
Old November 13th, 2005, 11:04 AM
Keith
Guest
 
Posts: n/a
Default Re: When shall i call my function?

<simonmarkjones@gmail.com> wrote in message
news:1116428752.584741.264280@g14g2000cwa.googlegr oups.com...[color=blue]
> Hi im a newbie to Access only started programing VBA in Access today.
>
> I've got a function that increments a number. I want to call this ONLY
> when the complete record has been filled out.
>
> Using the navigation buttons access creates a new record when the form
> is filled out. So i want to call the function when it does this.
>[/color]
It depends what you're doing with the incremented number but for starters,
have you tried the form's After Update event?

Regards,
Keith.
www.keithwilby.com


  #3  
Old November 13th, 2005, 11:04 AM
Salad
Guest
 
Posts: n/a
Default Re: When shall i call my function?

Keith wrote:[color=blue]
> <simonmarkjones@gmail.com> wrote in message
> news:1116428752.584741.264280@g14g2000cwa.googlegr oups.com...
>[color=green]
>>Hi im a newbie to Access only started programing VBA in Access today.
>>
>>I've got a function that increments a number. I want to call this ONLY
>>when the complete record has been filled out.
>>
>>Using the navigation buttons access creates a new record when the form
>>is filled out. So i want to call the function when it does this.
>>[/color]
>
> It depends what you're doing with the incremented number but for starters,
> have you tried the form's After Update event?
>
> Regards,
> Keith.
> www.keithwilby.com
>
>[/color]
The form's afterupdate event will work.

If the person is wanting to increment the number when the record is
complete, then it may be better to do it in the BeforeUpdate event. The
reason I mention this is that the person, if using a bound form to the
table, can check the NewRecord property since the increment may be
desired to only be increment at the time the record is created. The
person can check the validity in the BeforeUpdate event and if all the
fields pass muster keep cancel to False (the default) and then check the
NewRecord property.

To the original poster, Ex:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Nz(Me.Subject, "") = "" Then
'stop processing and don't save
MsgBox "Please enter a subject.", vbOKOnly, "Missing Data"
Me.Subject.SetFocus
Cancel = True
ElseIf Me.NewRecord Then
Me.IncrementField = 1 + 1 'or 2.
End If
End Sub
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles