copy value from textbox to filed in table

murray83

Games Collector
Local time
Today, 04:15
Joined
Mar 31, 2017
Messages
870
i have the following code determining the value of the customer in one text box

Code:
=IIf([SKUType]="GM",Mid([OrderNumber],11,4),IIf([SKUType]="BWS",Mid([OrderNumber],2,3),""))

i then would like this to be copied to the table filed customer ( at present its not as its unbound i believe )

i have thought about adding another text box which just equals the value of customer and search by this but that didn't work, maybe due to the code or that the item is unbound

have come across this following code but didn't add anything to the table, some input and pointers greatly appreciated

Code:
Private Sub Command48_Click() 
Dim RS As DAO.Recordset 
Set RS = CurrentDb.OpenRecordset("DeAllocation_Data", dbOpenDynaset) 
with RS 
.AddNew 
!Customer = Me![Customer] 
.Update 
RS.Close 
Set RS = Nothing 
End Sub

i have modified it so it has the correct name for the customer and table to open

Cheers
 

Attachments

You are correct that if it is unbound, you don't update the underlying field, and that formula DOES make it ineligible for direct binding. However...

You can create a bound field that you want updated and in the form's "BeforeUpdate" event, COPY the value from this computed field to the bound field. Then, to avoid any confusion, you can make the bound version of the field have .Visible=False so you can't see it, and you can shrink it's size to something ridiculously small that you can stick away in a corner somewhere so you couldn't even click on it. You do that by finding the field in design view and setting it to .Height= 1 and .Width=1 to make it really small. If you have to find it again in design view, you can just select it's name from the control selection drop-down in the upper right corner of the design view of that form. One last safeguard - you can also set it to have .Locked=True because locking it only means you can't update it from the GUI. You can still stick a value in it through code. I've had to use "hidden" fields like this where the user didn't need to see everything but the code DID, and this was the easiest way to handle that problem.
 
ok yeah i understand that but i tried the copy and to another textbox but the only way i could get it to work was change the control source which copied the customer but still wouldn't let me search

so what im asking is how if you dont mind
 
thanks but i finally managed to fix it by using this and putting my expression in here and then just changing the search filter

but thanks for your input and time
 

Attachments

  • works.png
    works.png
    1.7 KB · Views: 176

Users who are viewing this thread

Back
Top Bottom