PC Review


Reply
Thread Tools Rate Thread

How can I assign a value to a declared variable in a form

 
 
=?Utf-8?B?VGltbXk=?=
Guest
Posts: n/a
 
      28th Mar 2007
I need to assign a value from a table to a declared variable in VBA (a
declared variable "Number" takes on a value from table X) It's probably not
hard, but i'm confused about the syntax
 
Reply With Quote
 
 
 
 
Allen Browne
Guest
Posts: n/a
 
      28th Mar 2007
Use DLookup() to get the value from the field, e.g.:
X = DLookup(...

For help on DLookup(), see:
http://allenbrowne.com/casu-07.html

Note that X must be declared as a Variant, since the DLookup() could return
Null.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Timmy" <(E-Mail Removed)> wrote in message
news:B68E55E5-601D-4C29-9593-(E-Mail Removed)...
>I need to assign a value from a table to a declared variable in VBA (a
> declared variable "Number" takes on a value from table X) It's probably
> not
> hard, but i'm confused about the syntax


 
Reply With Quote
 
=?Utf-8?B?VGltbXk=?=
Guest
Posts: n/a
 
      28th Mar 2007
I did that but I get an "Overflow" error for some reason

"Allen Browne" wrote:

> Use DLookup() to get the value from the field, e.g.:
> X = DLookup(...
>
> For help on DLookup(), see:
> http://allenbrowne.com/casu-07.html
>
> Note that X must be declared as a Variant, since the DLookup() could return
> Null.
>
> --
> Allen Browne - Microsoft MVP. Perth, Western Australia
> Tips for Access users - http://allenbrowne.com/tips.html
> Reply to group, rather than allenbrowne at mvps dot org.
>
> "Timmy" <(E-Mail Removed)> wrote in message
> news:B68E55E5-601D-4C29-9593-(E-Mail Removed)...
> >I need to assign a value from a table to a declared variable in VBA (a
> > declared variable "Number" takes on a value from table X) It's probably
> > not
> > hard, but i'm confused about the syntax

>
>

 
Reply With Quote
 
Allen Browne
Guest
Posts: n/a
 
      28th Mar 2007
Did you start the procedure with:
Dim X As Variant

If that doesn't solve it post your procedure.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Timmy" <(E-Mail Removed)> wrote in message
news:01F30955-4136-4977-9845-(E-Mail Removed)...
>I did that but I get an "Overflow" error for some reason
>
> "Allen Browne" wrote:
>
>> Use DLookup() to get the value from the field, e.g.:
>> X = DLookup(...
>>
>> For help on DLookup(), see:
>> http://allenbrowne.com/casu-07.html
>>
>> Note that X must be declared as a Variant, since the DLookup() could
>> return
>> Null.
>>
>> "Timmy" <(E-Mail Removed)> wrote in message
>> news:B68E55E5-601D-4C29-9593-(E-Mail Removed)...
>> >I need to assign a value from a table to a declared variable in VBA (a
>> > declared variable "Number" takes on a value from table X) It's probably
>> > not
>> > hard, but i'm confused about the syntax


 
Reply With Quote
 
=?Utf-8?B?VGltbXk=?=
Guest
Posts: n/a
 
      28th Mar 2007
It did work. I changed it from an interger to a double and it works great.
Thank you very much

"Allen Browne" wrote:

> Did you start the procedure with:
> Dim X As Variant
>
> If that doesn't solve it post your procedure.
>
> --
> Allen Browne - Microsoft MVP. Perth, Western Australia
> Tips for Access users - http://allenbrowne.com/tips.html
> Reply to group, rather than allenbrowne at mvps dot org.
>
> "Timmy" <(E-Mail Removed)> wrote in message
> news:01F30955-4136-4977-9845-(E-Mail Removed)...
> >I did that but I get an "Overflow" error for some reason
> >
> > "Allen Browne" wrote:
> >
> >> Use DLookup() to get the value from the field, e.g.:
> >> X = DLookup(...
> >>
> >> For help on DLookup(), see:
> >> http://allenbrowne.com/casu-07.html
> >>
> >> Note that X must be declared as a Variant, since the DLookup() could
> >> return
> >> Null.
> >>
> >> "Timmy" <(E-Mail Removed)> wrote in message
> >> news:B68E55E5-601D-4C29-9593-(E-Mail Removed)...
> >> >I need to assign a value from a table to a declared variable in VBA (a
> >> > declared variable "Number" takes on a value from table X) It's probably
> >> > not
> >> > hard, but i'm confused about the syntax

>
>

 
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
Variable not assign when using query as form's record source. Dennis Microsoft Access Form Coding 3 28th Mar 2009 04:15 AM
Form/subform error You tried do assign a null value to a variable. Jorge Ribeiro Microsoft Access VBA Modules 4 17th Nov 2008 04:10 PM
Reference a variable declared in VBA James Microsoft Excel Worksheet Functions 3 12th Sep 2008 10:31 PM
Assign Current Form Name to a variable in VBA BlueWolvering Microsoft Access VBA Modules 3 11th Mar 2008 08:05 PM
Scope of Variable Declared Like This? George Microsoft ASP .NET 7 17th Mar 2004 06:42 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:53 PM.