Med kunstig intelligens skaber HP’s nye OmniBook X 14 en unik og skræddersyet brugeroplevelse målrettet dem, der ønsker høj ydeevne og intelligente funktioner
If you already have a form containing fields then you will need to manually place the fields where you want them, using code wont be able to decide that for you.
If you create a new form using the form wizard then Access will place them on the form lined up but not necessarily in the order you want them or where you want them.
Når brugerne går ind i skabelonen, åbnes en userform, der lader dem krydse forskellige felter af samt skrive i andre felter. På baggrund af disse felter dannes et brev.
Det er userformen jeg ønsker at danne automatisk, ikke noget i mit word-dokument, idet jeg allerede har styr på den del.
As I mentioned in my first comment, I dont see that using code is going to help much.
The code can not decide where among all the other fields the new fields is to be placed, that had to be a manual process. You could of course alter the code (manually) ever time you want to make a design alteration, but that's not going to save time.
You could have all the forms parameters in a table (position, field type, bound field .....and many others) And then make code which loops through records to create the form. But there is no simple solution
Terry...> I can see a lot of ways it would be easyer.
It would be easier to change the position in my code, because i only have to change the value one time on each object. If i have to move 50 boxes in the design view, i have to click on each box, and the type the new top-value.
I would assume it would be possible to calculate the top-value for each box, because they are placed with precise the same space.
"If i have to move 50 boxes in the design view, i have to click on each box, and the type the new top-value."
That's not correct, you can select one or more and move them together. You can also select all of them (Ctrl+A) at once and move them all together if need be.
Lets say you have 20 fields on a form all nicely spaced above each other. How do you tell the code which ones need to be moved to make room for another new field?
Its not a problem, takes a bit of time though, to make code which can read the coordinates of controls and if necessary move them around, but you still need some way of telling the code where to move them and which ones are to be moved.
There are built in features in Acces which can help you align controls etc. And you can find videos on YT showing how to use them. EG: https://www.youtube.com/watch?v=ATI5vcRA728
Terry...> I know i can mark all boxes and move them at once, but they have to be positioned with the mouse. It is not very easy to position them accurate.
In my comments I have just focused on controls on an Access form where using VBA it could be possible to move them about, and I also mentioned the ups and downs of using code for doing that.
If you want to move the controls on a word template from Access then things get a little more difficult because you need to automate Word to do this. Basically it means you start Word in the background and use that to make the design changes in the document/template.
To be honest, unless you are making changes to the template all the time then trying to make a system which can do this for you is going to take a long time.
"I do not know why you are mixing Access into this." :-) Not sure why we are either, for some silly reason I thought we were in category Access, sorry about that.
"Its a fairly small task for one who knows how to do it." I still dont think it is. VBA code still doesn't know where you want to move the existing fields from/to, and which ones. The code to move controls is simple, but the task of how to tell the code which ones to move isn't so simple. Or at least I dont think so.
Yes, please get back with your solution so we all can learn from it.
"Når der skal tilføjes en ny del, skal den ofte ind mellem de eksisterende elementer, hvilket tager lang tid idet alt gerne skal stå perfekt linet op."
Example: I have cover letter made as a template in Word. The userform has 50 different checkboxes in a particulier order.
Everytime the template is opened, the template should open with a empty userform, and then add the 50 different checkboxes in order specified in the programming code.
If i have to add a checkbox between the other checkboxes in the template, i can do that by adding the checkbox in the programming code between the other checkboxes.
When the userform has all checkboxes added, i do not need to move them around.
Et lille eksempel på hvad jeg ville kan ses nedenfor.
Indsættelse af 3 checkboxe:
Private Sub UserForm_Initialize() Dim placeringTop, placeringLeft As Integer placeringTop = 20 placeringLeft = 20
Set addElement1 = Userform_Folgebrev.Controls.Add("forms.checkbox.1", "checkbox1") With addElement1 .Width = 500 .Left = placeringLeft .Top = placeringTop .Caption = "Dette er en test 1" End With
Set addElement2 = Userform_Folgebrev.Controls.Add("forms.checkbox.1", "checkbox2") With addElement2 .Width = 500 .Left = placeringLeft .Top = addElement1 + addElement1.Top + 2 .Caption = "Dette er en test 2" End With
Set addElement3 = Userform_Folgebrev.Controls.Add("forms.checkbox.1", "checkbox3") With addElement3 .Width = 500 .Left = placeringLeft .Top = addElement2 + addElement2.Top + 2 .Caption = "Dette er en test 3" End With End Sub
Indsættelse af 1 ekstra checkbox:
Private Sub UserForm_Initialize() Dim placeringTop, placeringLeft As Integer placeringTop = 20 placeringLeft = 20
Set addElement1 = Userform_Folgebrev.Controls.Add("forms.checkbox.1", "checkbox1") With addElement1 .Width = 500 .Left = placeringLeft .Top = placeringTop .Caption = "Dette er en test 1" End With
Set addElement1a = Userform_Folgebrev.Controls.Add("forms.checkbox.1", "checkbox1a") With addElement1a .Width = 500 .Left = placeringLeft .Top = addElement1 + addElement1.Top + 2 .Caption = "Dette er en test 1a" End With
Set addElement2 = Userform_Folgebrev.Controls.Add("forms.checkbox.1", "checkbox2") With addElement2 .Width = 500 .Left = placeringLeft .Top = addElement1a + addElement1a.Top + 2 .Caption = "Dette er en test 2" End With
Set addElement3 = Userform_Folgebrev.Controls.Add("forms.checkbox.1", "checkbox3") With addElement3 .Width = 500 .Left = placeringLeft .Top = addElement2 + addElement2.Top + 2 .Caption = "Dette er en test 3" End With End Sub
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.