I have a data entry form that allows the user to add gift idea items based on category, for example, clothing, toys etc. The user can enter the data in a single form field separated by commas. When I originally set this database up, I allowed comma delimited data to be saved in a single field which I have since learned is poor design, plus it is causing problems for me with some other features I want to add to the database. I have created VBA code to split up the strings into individual items and then store it in separate text boxes in another form. What I would like to do is run that code on the initial data entry so that when the record is saved to the table, the original strings are split and a single item is saved to each field of the table. I have no clue how to do that. Here is a portion of the code I used to split the strings and store each item in s separate text box. It uses the strsplit function. It loops through the comma delimited list and takes each individual item and places it in sequentially named text boxes.
Private Sub Form_Open(Cancel As Integer)
'code to parse the clothing field
Dim temp() As String
Dim y As Integer
Dim BS, BY As String
Me.Textbox35.SetFocus
strinput = Me.Textbox35.Text
temp() = strsplit(strinput)
For y = 0 To UBound(temp())
Me("Textbox" & y).SetFocus
Me("Textbox" & y).Text = temp(y)
Textbox35.Visible = False
Next
I'm not sure where to even start the code Could I leave the data entry fields unbound and bind the output textboxes to the underlying table? I was wondering if there is a way to avoid the whole step of putting the parsed data into textboxes and have it saved directly to the table?
thanks