# Macro to copy a field from a View Table on Base

I am trying to create a push button on a form to copy a field from a view table depending on the entry,

For example on entry 1 of the form, I want to reference entry 1 on the view table. but I don't know how to reference the view table or match the entry number from the form to the view table

This is a continuation of a previous question which can be viewed here.

I have included a file as an example of the current DB.

What I want to do is have the format of the field FieldA, FieldB, FieldC and FieldD on the clipboard, as indicated on View1 from the file below.

C:\fakepath\1532573290790838.odb

edit retag close merge delete

@ehesh This question is very vague. The View is based upon information from other table(s). A View can be in any sequence and not necessarily the same as where it originated from. What relation is there for 'entry 1' on the form and 'entry 1' in the View? Should be a connection. Also you need to be specific as to what is being copied & what you are going to do with it. Why is a View even involved? Is this concerning the concatenated field previously discussed? Need clarity.

( 2018-07-30 22:43:51 +0200 )edit

yeah, it is regarding the concatenated field previously discussed. I added more details to my question above as well as a modified version of the file you initially provided. I removed the text boxes since they were not really needed if I had them on the View, but I kept the code/formula in order to set up View1. What I need now is to have them on the concatenated field on the clipboard with the push of the button

( 2018-07-31 00:08:59 +0200 )edit

So you just want the result on the clipboard?

( 2018-07-31 00:35:12 +0200 )edit

Sort by » oldest newest most voted

Hello,

Edited version:

Apoligies for not reading your comment close enough. You still don't need a view.

In my opinion this is in opposition to all I've stated before and even further now. Why even create a View when, if you insist on duplicating this information, you can do it right at entry time. Hope you understand that macros are not the easiest thing to comprehend. It takes some time to absorb the details on how to do things. Here is a working sample:

Sample ---- DisplayConcatonatedFields.odb

Modified form FieldTable to be FieldTableWithButton and the push button copies the field to the clipboard using the macro found here -> BASIC Macro to Copy textbox value to clipboard. It was only slightly modified to fit the situation.

Since, through experience, I realize the tasks ahead for you, here is the best reference for LO macros. Book written by Andrew Pitonyak (PDF) - Open Office Macros Explained.

more

BTW The text boxes on the form displaying the concatenated text are not necessary for the macro to work.

( 2018-07-31 01:02:19 +0200 )edit

After I click the button the field labels disappear. Is that supposed to happen?

( 2018-08-03 00:23:27 +0200 )edit

No. You have not stated (in any of your questions) what OS & which LO version you are using. This is basic info when asking any question (Base should include more depending on the question). Please provide. Did this happen on the provided sample or on your form? Did the copy to clipboard work for you? Have no problems on Mint 18.3 as you state and copy to clipboard works.

( 2018-08-03 00:53:48 +0200 )edit

nevermind. if I scroll they come back.

( 2018-08-03 01:17:36 +0200 )edit