Copy Fields into other fields within the same form

R

raymondp

I have a combo box with 4 columns. I want to store the values in these
columns in the database. What I've been able to do is create additional text
boxes to return the columns using the expression, =SiteIDBox.column(1), and
so forth. In order to get it to work I had to put into the control source.
I tired in the default value but it didn't work there. Is there a way to get
that to work? If not, what I would like to do is create a button that will
copy the values from the fields with the expression to fields with the
appropriate control source within the same form so that the data is stored.
Any help would be great.
 
P

pietlinden

I have a combo box with 4 columns. I want to store the values in these
columns in the database. What I've been able to do is create additional text
boxes to return the columns using the expression, =SiteIDBox.column(1), and
so forth. In order to get it to work I had to put into the control source.
I tired in the default value but it didn't work there. Is there a way to get
that to work? If not, what I would like to do is create a button that will
copy the values from the fields with the expression to fields with the
appropriate control source within the same form so that the data is stored.
Any help would be great.

you just put the code in the afterupdate event of the combobox.
Me.txt1=me.cboX.Columns(0)
etc.
 
L

Larry Daugherty

Try turning your code "upside down" and put it into the AfterUpdate
event of the combobox. You've already figured out the harder part
which is getting the column index correctly.

HTH
 
R

raymondp

Larry, I'm confused by what you mean by turning the code "upside down."

When I tried to put the code Me.Text113=Me.cboSiteIDBox.column(1) into the
AfterUpdate event in the combo box, I get the following error,

"TAO Daily Log Database can't find the macro 'Me.'
The macro (or its macro group) doesn't exist, or the macro is new but hasn't
been saved.
Note that when you enter the macrogroupname.macroname syntax in an argument,
you must specify the name the macro's macro group was last saved under."

SiteIDBox is the name of the combo box that has the values I want to store.
Text113 is the name of the text box where I want to store the values.

Also, what is 'Me?'
 
L

Larry Daugherty

While "turning the code upside down" is hardly correct terminology the
meaning was that instead of having the code say something equivalent
to change the code phrase from " Put the value you find over there (in
the cbo) over here (in the text control)" to "put the value you find
in this control and column(n) over in this text control". Sorry for
the confusion. You still seem to have gotten the correct idea.

"me" refers to the Form or Report where the code is executing..

putting the line of code

Me!Text113 = Me!cboSiteIDBox.column(1)

into the AfterUpdate event of cboSiteIDBox would cause the value in
the 2nd column of the combobox - to be placed in the textbox control
named Text113 on the currently running Form.

HTH
-Larry-
--
 
R

raymondp

Thanks for clearing that up for me.

I put in the code

Me!Text113 = Me!cboSiteIDBox.column(1)

into the AfterUpdate event in the combo box, but I still got the error I
mentioned before (Macro doesn't exist and so forth).
What am I doing wrong? Or what haven't I done yet that I need to do to get
this to work? This is driving me nuts.
 
L

Larry Daugherty

I haven't got a clue. If I had your stuff on my system I'd be better
able to analyze and debug it. Are you single stepping in the
AfterUpdate event? Are you sure that the line in question is the one
causing the error?
 
R

raymondp

I'm a novice user of Access, so I'm not sure what you mean by single stepping
and I have no clue if the line in question is the one causing the error.
What about creating a button that will copy the values from one field into
other fields on the same form? Is this possible?
If you would like to debug what I'm doing, I can send you a copy of the
database I'm working with. If you don't want to put your email address on
this public site, you can send me an email at [email protected].
I really appreciate the help you've given thus far. Thanks.

-Ray
 
R

raymondp

Thanks again for your help, but I figured out how to fill in the values
through a series of RunCommand macros.

raymondp said:
I'm a novice user of Access, so I'm not sure what you mean by single stepping
and I have no clue if the line in question is the one causing the error.
What about creating a button that will copy the values from one field into
other fields on the same form? Is this possible?
If you would like to debug what I'm doing, I can send you a copy of the
database I'm working with. If you don't want to put your email address on
this public site, you can send me an email at [email protected].
I really appreciate the help you've given thus far. Thanks.

-Ray
 
L

Larry Daugherty

Hi Ray,

You were using the word "Macro" correctly as it applies to Access.
Many people use that word to mean VBA code in Access because that's
the term used in the other office applications.

For the reasons you were experiencing, among others, experienced
developers don't use macros. They use VBA. It is impossible to
single step or make any other use of the debugger when running Access
Macros. If you intend to develop in Access I recommend that you bite
the bullet and learn how to use VBA - sooner is better than later.
There is a tool to convert Access macros to VBA. Once that's done you
should use VBA exclusively except in those very few special cases
where you can't. You can do things with VBA that you can't with
macros.

HTH
--
-Larry-
--

raymondp said:
Thanks again for your help, but I figured out how to fill in the values
through a series of RunCommand macros.
 
Top