Unbound and Bound textbox data transfer (3 Viewers)

yoffenddeh

New member
Local time
Today, 23:54
Joined
Mar 20, 2020
Messages
24
Please can someone show me how to upload the data in an unbound textbox into a bound textbox for it to appear in the table. The two textbox are on the same form.

I used vba code in access to provide data into the unbound textbox which I need to enter into the bound textbox that is connected to sql server. I used the simple transfer method; using the control source, but the data is not appearing on the sql server table. I want to use vba code using the after update event to perform the transfer and update the sql server table
 

theDBguy

I’m here to help
Staff member
Local time
Today, 15:54
Joined
Oct 29, 2018
Messages
21,474
Hi. You said you use vba to populate the unbound textbox. If so, it won't fire the AfterUpdate event. You can just add the assignment to the bound textbox at the end of your vba.
 

yoffenddeh

New member
Local time
Today, 23:54
Joined
Mar 20, 2020
Messages
24
The data that is used to populate the unbound textbox, is from an click event button command that loads it from a dlookup table. I want to update the bound textbox with data in the unbound textbox. Vba afterupdate or beforeupdate using the vba instruction
me.bound text control source name or textbox name.value=me.unbound textbox name.value
is giving an error message.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 15:54
Joined
Oct 29, 2018
Messages
21,474
The data that is used to populate the unbound textbox, is from an click event button command that loads it from a dlookup table. I want to update the bound textbox with data in the unbound textbox. Vba afterupdate or beforeupdate using the vba instruction
me.bound text control source name or textbox name.value=me.unbound textbox name.value
is giving an error message.
What was the error message? Also, what happens if you assign the value in the Click event of the button?
 

vba_php

Forum Troll
Local time
Today, 17:54
Joined
Oct 6, 2019
Messages
2,880
Vba afterupdate or beforeupdate using the vba instruction
me.bound text control source name or textbox name.value=me.unbound textbox name.value
is giving an error message.
the AFTERUPDATE() or BEFOREUPDATE() or *what* entity? the form or the box?
 

yoffenddeh

New member
Local time
Today, 23:54
Joined
Mar 20, 2020
Messages
24
I have done for both form and bound textbox, the error is the same.
 

vba_php

Forum Troll
Local time
Today, 17:54
Joined
Oct 6, 2019
Messages
2,880
dbguy asked you what the error was. furthermore, if you are throwing data from an unbound box to a bound box, the setup of the form and table might be a little strange. I don't see too many of these types of questions. Can's say I've ever done this myself, ever.
 

Micron

AWF VIP
Local time
Today, 18:54
Joined
Oct 20, 2018
Messages
3,478
I have done for both form and bound textbox, the error is the same.
That doesn't tell us what the error message and error number is. This
I used the simple transfer method; using the control source,
makes me think you have put the DLookup expression in the unbound textbox source property. If so, you cannot edit a calculated control.

We should be asking why you're looking up a value, putting it into an unbound textbox then wanting to put it into a bound textbox. I would think that the lookup could be in the bound textbox directly (which means you could not edit it) or why the value being looked up is not just part of the form recordsource and bind a control to that as is normally done.

If you must do this, you will have to write code to put the value in the unbound, but I still don't see the need for it the unbound control when that code could simply write the value to the bound textbox.
 

yoffenddeh

New member
Local time
Today, 23:54
Joined
Mar 20, 2020
Messages
24
Please find attached the error message and the accompanying vba code
 

yoffenddeh

New member
Local time
Today, 23:54
Joined
Mar 20, 2020
Messages
24
That doesn't tell us what the error message and error number is. This
makes me think you have put the DLookup expression in the unbound textbox source property. If so, you cannot edit a calculated control.

We should be asking why you're looking up a value, putting it into an unbound textbox then wanting to put it into a bound textbox. I would think that the lookup could be in the bound textbox directly (which means you could not edit it) or why the value being looked up is not just part of the form recordsource and bind a control to that as is normally done.

If you must do this, you will have to write code to put the value in the unbound, but I still don't see the need for it the unbound control when that code could simply write the value to the bound textbox.

No I have not got any dlookup expression in the unbound textbox source property or form source property. I was expecting a direct data transfer vba code in the afterupdate event would have solve the problem, unfortunately this has not happened.
 

Micron

AWF VIP
Local time
Today, 18:54
Joined
Oct 20, 2018
Messages
3,478
You have declared the user and level variables at the level of your command button, then you close the form and try to use the values of the variables. At that point they no longer exist. You either have to give the variables a wider scope (such as global) or open the next form and either a) retrieve the values from the first form, then close the first form (you can hide the first form before getting the values) or b) pass the values to the second form by using OpenArgs property when opening that form. Anything other than those two methods gets more complicated.
 

zeroaccess

Active member
Local time
Today, 17:54
Joined
Jan 30, 2020
Messages
671
You have declared the user and level variables at the level of your command button, then you close the form and try to use the values of the variables. At that point they no longer exist. You either have to give the variables a wider scope (such as global) or open the next form and either a) retrieve the values from the first form, then close the first form (you can hide the first form before getting the values) or b) pass the values to the second form by using OpenArgs property when opening that form. Anything other than those two methods gets more complicated.
Are OpenArgs really needed?

I just say Forms!frmName!somecontrol = control on selection/popup form
 

theDBguy

I’m here to help
Staff member
Local time
Today, 15:54
Joined
Oct 29, 2018
Messages
21,474
Please find attached form for which assistance is being requested
Hi. I looked at your files and it seems Micron already got it figured out in Post #18. Have you tried his suggestions?
 

Users who are viewing this thread

Top Bottom