Copy a Num Feld to an other Form (1 Viewer)

Wasser

New member
Local time
Today, 10:00
Joined
Oct 9, 2023
Messages
1
Hello, guys, i have just now updated my profile. In my first attempt i tried to write in my native language German, but my Keyboard failed.
I am looking for a support in that Forum. Aktual just simple, i wish to copy a Number Field from one Formular to an other. that sound simple but is not.

here a sample of my last coding

Sub dingsda...

FomsF1!TNr = FormsF2!TNr ' TNR is a Number and this number should transferred copied to Forms F1
' that sample does'n work properly

end sub
.
my first attempt with a text field and a "sendkey" was successful if I selected the field with the cursor beforehand.

I'm still in the process of finding a property to mark a field with VBA code?

If someone there to help please thanks in advance

Hier an other sample

Sub...

DoCmd.GoToControl "TNr" 'Position Cursor to NumFld "TNr"

SendKeys "^{c}", True ' Send ctlT + C to cut TNr it should be stored in to clipboard, but it does'n
' it copied the total Sub...instead of the content of "TNr"
DoCmd.Close acForm, "FThema"

End Sub


Thanks in advance
 

Jon

Access World Site Owner
Staff member
Local time
Today, 09:00
Joined
Sep 28, 1999
Messages
7,396
Welcome to Access World! We're so happy to have you join us as a member of our community. As the most active Microsoft Access discussion forum on the internet, with posts dating back more than 20 years, we have a wealth of knowledge and experience to share with you.

We're a friendly and helpful community, so don't hesitate to ask any questions you have or share your own experiences with Access. We're here to support you and help you get the most out of this powerful database program.

To get started, we recommend reading the post linked below. It contains important information for all new users of the forum:

https://www.access-programmers.co.uk/forums/threads/new-member-read-me-first.223250/

We hope you have a great time participating in the discussion and learning from other Access enthusiasts. We look forward to having you around!
 

bob fitz

AWF VIP
Local time
Today, 09:00
Joined
May 23, 2011
Messages
4,726
what are the forms called?
 

bob fitz

AWF VIP
Local time
Today, 09:00
Joined
May 23, 2011
Messages
4,726
Try:
Forms![YourFormName].[YourTextboxName] = Me.ActiveControl
in the AfterUpdate event of the second textbox.
Substitute YourFormName with the name of the first form.
Substitute YourTextboxName with the name of the first textbox.
Both forms will need to be open.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 04:00
Joined
Feb 19, 2002
Messages
43,275
We need to know what error message you are getting. You probably have to translate it for us though.

Using Me.ActiveControl is dangerous because you and Access might think a different control is active. Your original code is correct provided that both names are correct and the form references are correct. I would use:

Forms![YourFormName]![YourTextboxName] = Me.YourOtherTextboxName

When you are referencing controls in the form which is running the code, always use the "Me." syntax to reference controls. It is more efficient because the interpreter knows immediately in which library/module the field being referenced is defined.
 

sonic8

AWF VIP
Local time
Today, 10:00
Joined
Oct 27, 2015
Messages
998
FomsF1!TNr = FormsF2!TNr ' TNR is a Number and this number should transferred copied to Forms F1
' that sample does'n work properly
Rewrite that as
Code:
Forms!F1!TNr = Forms!F2!TNr
and then it should work.
 

Users who are viewing this thread

Top Bottom