PC Review


Reply
Thread Tools Rate Thread

access 2002, run a query to update a form field when button isclicked?

 
 
Broons Bane
Guest
Posts: n/a
 
      18th Apr 2009
Sorry, am fairly new to access, but not databases,

i have a query nextmembernumber which returns one and only one
integer. I want to associate this query with a new button on a form,
so that (pseudo code):

if the new button is clicked then
if the membernumber form field is null then
execute nextmembernumber query and place the result in the
membernumber form field
end if
end if

how do i do it?

Thanks in anticipation
 
Reply With Quote
 
 
 
 
Ken Snell MVP
Guest
Posts: n/a
 
      18th Apr 2009
Replace generic names with real names:

Private Sub CommandButtonName_Click()
If IsNull(Me.MemberNumber.Value) = True Then _
Me.MemberNumber.Value = DLookup("FieldNameInQuery", _
"NextMemberNumber")
End Sub

--

Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/


"Broons Bane" <(E-Mail Removed)> wrote in message
news:31eff8ee-8071-4842-bcec-(E-Mail Removed)...
> Sorry, am fairly new to access, but not databases,
>
> i have a query nextmembernumber which returns one and only one
> integer. I want to associate this query with a new button on a form,
> so that (pseudo code):
>
> if the new button is clicked then
> if the membernumber form field is null then
> execute nextmembernumber query and place the result in the
> membernumber form field
> end if
> end if
>
> how do i do it?
>
> Thanks in anticipation



 
Reply With Quote
 
Tom van Stiphout
Guest
Posts: n/a
 
      18th Apr 2009
On Sat, 18 Apr 2009 06:40:34 -0700 (PDT), Broons Bane
<(E-Mail Removed)> wrote:

private sub myNewButton_Click()
if isnull(Me.myMembernumber)
Me.myMembernumber = DLookup("myQueryField", "nextmembernumber")
end if
end sub
(replace myObjectNames with yours)

Personally I would make that an Autonumber, so Access automatically
provides the next number. Your technique is appropriate if the number
is not just a meaningless number but a very specific one.

-Tom.
Microsoft Access MVP


>Sorry, am fairly new to access, but not databases,
>
>i have a query nextmembernumber which returns one and only one
>integer. I want to associate this query with a new button on a form,
>so that (pseudo code):
>
> if the new button is clicked then
> if the membernumber form field is null then
> execute nextmembernumber query and place the result in the
>membernumber form field
> end if
> end if
>
>how do i do it?
>
>Thanks in anticipation

 
Reply With Quote
 
Broons Bane
Guest
Posts: n/a
 
      18th Apr 2009
On Apr 18, 5:01*pm, Tom van Stiphout <tom7744.no.s...@cox.net> wrote:
> On Sat, 18 Apr 2009 06:40:34 -0700 (PDT), Broons Bane
>
> <newsgrou...@yahoo.com> wrote:
>
> private sub myNewButton_Click()
> if isnull(Me.myMembernumber)
> * Me.myMembernumber = DLookup("myQueryField", "nextmembernumber")
> end if
> end sub
> (replace myObjectNames with yours)
>
> Personally I would make that an Autonumber, so Access automatically
> provides the next number. Your technique is appropriate if the number
> is not just a meaningless number but a very specific one.
>
> -Tom.
> Microsoft Access MVP
>
> >Sorry, am fairly new to access, but not databases,

>
> >i have a query nextmembernumber which returns one and only one
> >integer. I want to associate this query with a new button on a form,
> >so that (pseudo code):

>
> > if the new button is clicked then
> > * *if the membernumber form field is null then
> > * * * *execute nextmembernumber query and place the result in the
> >membernumber form field
> > * *end if
> > end if

>
> >how do i do it?

>
> >Thanks in anticipation


Thank you Tom, much appreciated.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
update query from command button on form Mike Microsoft Access Queries 7 7th Sep 2005 04:35 PM
Access 2002 field-level security: limit access to form fields =?Utf-8?B?U3RldmVJblRhbGx5Rmw=?= Microsoft Access Security 3 3rd Mar 2005 12:14 PM
Update field with button from Form Hank from Oregon Microsoft Access Forms 0 9th Mar 2004 08:40 PM
update query from form button JulieD Microsoft Access Forms 2 2nd Nov 2003 07:32 AM
Update Query in Access 2002 Keith Fentress Microsoft Access Queries 2 15th Sep 2003 08:50 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:18 PM.