Passing a Field from an Active Record to a Function

G

Guest

Hello,

I am trying to pass a value in a particular field into a function, but I
can't seem to figure out how to get it to work. Basically, when browsing
through records I want to run a function that will disable certain controls
for records where the "Complete" field is 1, and enable all the controls when
the "Complete" field is 0. To do this, I'm trying to pass the value in the
"Complete" field. To get the code to even run with getting a data type
mismatch I had to code my function to expect to receive a Variant. When I use
the VarType function on the variable, it tells me that the type is 9, a
vbObject. How can I work with a vbObject? I can't seem to find any
information on this.

Thanks,
Graham
 
B

Baz

Sounds like you are inadvertantly passing a control rather than it's value.
Please post your code.
 
G

Guest

I barely have any code so far because I don't know how to perform any actions
on this vbObject.

My Table is named TDREV and is set up with basically the following columns:
RevisionID AutoNumber
Document Text
Revision Text
Complete Number

The source for my form is this TDREV table, limited to only the document
number you select select from a listbox on the form, referenced like
[FORMS]![Revision Control].[Documents]

When you select the document from the listbox, it runs a macro that calls
the public function CheckComplete(Complete)

Public Function CheckComplete(Complete as Variant)
MsgBox VarType(Complete)
End Function

And all that is displayed is "9". I've tried to use CDbl and CStr etc. to
convert it to something I'm a little more familiar with, but that always
produces errors.

I hope this is a better explanation!

Graham
 
A

Allen Browne

Try calling it like this:
Call CheckComplete(Me.Complete.Value)
so that it passes the value of the check box, not the entire object.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

AlwaysFroosh! said:
I barely have any code so far because I don't know how to perform any
actions
on this vbObject.

My Table is named TDREV and is set up with basically the following
columns:
RevisionID AutoNumber
Document Text
Revision Text
Complete Number

The source for my form is this TDREV table, limited to only the document
number you select select from a listbox on the form, referenced like
[FORMS]![Revision Control].[Documents]

When you select the document from the listbox, it runs a macro that calls
the public function CheckComplete(Complete)

Public Function CheckComplete(Complete as Variant)
MsgBox VarType(Complete)
End Function

And all that is displayed is "9". I've tried to use CDbl and CStr etc. to
convert it to something I'm a little more familiar with, but that always
produces errors.

I hope this is a better explanation!

Graham




AlwaysFroosh! said:
Hello,

I am trying to pass a value in a particular field into a function, but I
can't seem to figure out how to get it to work. Basically, when browsing
through records I want to run a function that will disable certain
controls
for records where the "Complete" field is 1, and enable all the controls
when
the "Complete" field is 0. To do this, I'm trying to pass the value in
the
"Complete" field. To get the code to even run with getting a data type
mismatch I had to code my function to expect to receive a Variant. When I
use
the VarType function on the variable, it tells me that the type is 9, a
vbObject. How can I work with a vbObject? I can't seem to find any
information on this.

Thanks,
Graham
 
G

Guest

I tried this and it doesn't work. The value is not coming from a box, it's
coming directly from the active record, from the field named Complete. When I
try this, I get the following error:

The object doesn't contain the Automation object 'Me.'

You tried to run a Visual Basic procedure to se a property or method for an
object. However, the component doesn't make the property or method available
for Automation operations.

Check the component's documentation for information on the properties and
methods it makes available for Automation operations.


Any other ideas?
Graham

Allen Browne said:
Try calling it like this:
Call CheckComplete(Me.Complete.Value)
so that it passes the value of the check box, not the entire object.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

AlwaysFroosh! said:
I barely have any code so far because I don't know how to perform any
actions
on this vbObject.

My Table is named TDREV and is set up with basically the following
columns:
RevisionID AutoNumber
Document Text
Revision Text
Complete Number

The source for my form is this TDREV table, limited to only the document
number you select select from a listbox on the form, referenced like
[FORMS]![Revision Control].[Documents]

When you select the document from the listbox, it runs a macro that calls
the public function CheckComplete(Complete)

Public Function CheckComplete(Complete as Variant)
MsgBox VarType(Complete)
End Function

And all that is displayed is "9". I've tried to use CDbl and CStr etc. to
convert it to something I'm a little more familiar with, but that always
produces errors.

I hope this is a better explanation!

Graham




AlwaysFroosh! said:
Hello,

I am trying to pass a value in a particular field into a function, but I
can't seem to figure out how to get it to work. Basically, when browsing
through records I want to run a function that will disable certain
controls
for records where the "Complete" field is 1, and enable all the controls
when
the "Complete" field is 0. To do this, I'm trying to pass the value in
the
"Complete" field. To get the code to even run with getting a data type
mismatch I had to code my function to expect to receive a Variant. When I
use
the VarType function on the variable, it tells me that the type is 9, a
vbObject. How can I work with a vbObject? I can't seem to find any
information on this.

Thanks,
Graham
 
A

Allen Browne

Ah: there is no control named "Complete"?

Is there any chance of adding a text box named Complete, and bound to the
Complete field?

Otherwise it is an object of type AccessField, and there are bugs with that
type.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

AlwaysFroosh! said:
I tried this and it doesn't work. The value is not coming from a box, it's
coming directly from the active record, from the field named Complete.
When I
try this, I get the following error:

The object doesn't contain the Automation object 'Me.'

You tried to run a Visual Basic procedure to se a property or method for
an
object. However, the component doesn't make the property or method
available
for Automation operations.

Check the component's documentation for information on the properties and
methods it makes available for Automation operations.


Any other ideas?
Graham

Allen Browne said:
Try calling it like this:
Call CheckComplete(Me.Complete.Value)
so that it passes the value of the check box, not the entire object.

AlwaysFroosh! said:
I barely have any code so far because I don't know how to perform any
actions
on this vbObject.

My Table is named TDREV and is set up with basically the following
columns:
RevisionID AutoNumber
Document Text
Revision Text
Complete Number

The source for my form is this TDREV table, limited to only the
document
number you select select from a listbox on the form, referenced like
[FORMS]![Revision Control].[Documents]

When you select the document from the listbox, it runs a macro that
calls
the public function CheckComplete(Complete)

Public Function CheckComplete(Complete as Variant)
MsgBox VarType(Complete)
End Function

And all that is displayed is "9". I've tried to use CDbl and CStr etc.
to
convert it to something I'm a little more familiar with, but that
always
produces errors.

I hope this is a better explanation!

Graham




:

Hello,

I am trying to pass a value in a particular field into a function, but
I
can't seem to figure out how to get it to work. Basically, when
browsing
through records I want to run a function that will disable certain
controls
for records where the "Complete" field is 1, and enable all the
controls
when
the "Complete" field is 0. To do this, I'm trying to pass the value in
the
"Complete" field. To get the code to even run with getting a data type
mismatch I had to code my function to expect to receive a Variant.
When I
use
the VarType function on the variable, it tells me that the type is 9,
a
vbObject. How can I work with a vbObject? I can't seem to find any
information on this.

Thanks,
Graham
 
G

Guest

Yeah, I thought about having just a dummy field on my form and just setting
it to be invisible, but I was hoping that there would be a cleaner way to do
it. I will give this a try.

Thanks,
Graham


Allen Browne said:
Ah: there is no control named "Complete"?

Is there any chance of adding a text box named Complete, and bound to the
Complete field?

Otherwise it is an object of type AccessField, and there are bugs with that
type.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

AlwaysFroosh! said:
I tried this and it doesn't work. The value is not coming from a box, it's
coming directly from the active record, from the field named Complete.
When I
try this, I get the following error:

The object doesn't contain the Automation object 'Me.'

You tried to run a Visual Basic procedure to se a property or method for
an
object. However, the component doesn't make the property or method
available
for Automation operations.

Check the component's documentation for information on the properties and
methods it makes available for Automation operations.


Any other ideas?
Graham

Allen Browne said:
Try calling it like this:
Call CheckComplete(Me.Complete.Value)
so that it passes the value of the check box, not the entire object.

I barely have any code so far because I don't know how to perform any
actions
on this vbObject.

My Table is named TDREV and is set up with basically the following
columns:
RevisionID AutoNumber
Document Text
Revision Text
Complete Number

The source for my form is this TDREV table, limited to only the
document
number you select select from a listbox on the form, referenced like
[FORMS]![Revision Control].[Documents]

When you select the document from the listbox, it runs a macro that
calls
the public function CheckComplete(Complete)

Public Function CheckComplete(Complete as Variant)
MsgBox VarType(Complete)
End Function

And all that is displayed is "9". I've tried to use CDbl and CStr etc.
to
convert it to something I'm a little more familiar with, but that
always
produces errors.

I hope this is a better explanation!

Graham




:

Hello,

I am trying to pass a value in a particular field into a function, but
I
can't seem to figure out how to get it to work. Basically, when
browsing
through records I want to run a function that will disable certain
controls
for records where the "Complete" field is 1, and enable all the
controls
when
the "Complete" field is 0. To do this, I'm trying to pass the value in
the
"Complete" field. To get the code to even run with getting a data type
mismatch I had to code my function to expect to receive a Variant.
When I
use
the VarType function on the variable, it tells me that the type is 9,
a
vbObject. How can I work with a vbObject? I can't seem to find any
information on this.

Thanks,
Graham
 
G

Guest

Yup, that did it. Now I'm not even passing the control, I'm just referencing
it in my code using Me.CompleteCheck.Value where CompleteCheck is the name of
my dummy control in my form.

Thank you!


AlwaysFroosh! said:
Yeah, I thought about having just a dummy field on my form and just setting
it to be invisible, but I was hoping that there would be a cleaner way to do
it. I will give this a try.

Thanks,
Graham


Allen Browne said:
Ah: there is no control named "Complete"?

Is there any chance of adding a text box named Complete, and bound to the
Complete field?

Otherwise it is an object of type AccessField, and there are bugs with that
type.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

AlwaysFroosh! said:
I tried this and it doesn't work. The value is not coming from a box, it's
coming directly from the active record, from the field named Complete.
When I
try this, I get the following error:

The object doesn't contain the Automation object 'Me.'

You tried to run a Visual Basic procedure to se a property or method for
an
object. However, the component doesn't make the property or method
available
for Automation operations.

Check the component's documentation for information on the properties and
methods it makes available for Automation operations.


Any other ideas?
Graham

:

Try calling it like this:
Call CheckComplete(Me.Complete.Value)
so that it passes the value of the check box, not the entire object.

I barely have any code so far because I don't know how to perform any
actions
on this vbObject.

My Table is named TDREV and is set up with basically the following
columns:
RevisionID AutoNumber
Document Text
Revision Text
Complete Number

The source for my form is this TDREV table, limited to only the
document
number you select select from a listbox on the form, referenced like
[FORMS]![Revision Control].[Documents]

When you select the document from the listbox, it runs a macro that
calls
the public function CheckComplete(Complete)

Public Function CheckComplete(Complete as Variant)
MsgBox VarType(Complete)
End Function

And all that is displayed is "9". I've tried to use CDbl and CStr etc.
to
convert it to something I'm a little more familiar with, but that
always
produces errors.

I hope this is a better explanation!

Graham




:

Hello,

I am trying to pass a value in a particular field into a function, but
I
can't seem to figure out how to get it to work. Basically, when
browsing
through records I want to run a function that will disable certain
controls
for records where the "Complete" field is 1, and enable all the
controls
when
the "Complete" field is 0. To do this, I'm trying to pass the value in
the
"Complete" field. To get the code to even run with getting a data type
mismatch I had to code my function to expect to receive a Variant.
When I
use
the VarType function on the variable, it tells me that the type is 9,
a
vbObject. How can I work with a vbObject? I can't seem to find any
information on this.

Thanks,
Graham
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top