Hi
Before I explain the issue in detail I though I would put the simple version: How do I specify the field in a datasheet I want to update to a value. I am stepping through the records but each time I update the field in the datasheet (Me.ProductSectionName.Value ) it changes the field value for every record to the new value. I need to specify somehow to only update the current row.?
I have a datasheet form that is populated from a query that brings back PRODUCT NAME and PRODUCT REF NUMBER. The datasheet populates fine. I have gone into design view for the datasheet and added some extra columns. Again this seems fine. On load the extra columns are blank (as you expect).
I will be using these extra columns to display calculated data (results of other queries and calculations in vba). The first thing I wanted to do was populate a column in the datasheet with the first word from the PRODUCT NAME when this value changes. To do this I used:
Form.SetFocus
Me.Recordset.MoveFirst
For i = 0 To NumRecords - 1
DoCmd.GoToRecord , , acNext
ProductNameTextCurrent = Me.Short_description.Value
intPos = InStr(ProductNameTextCurrent, " ")
If intPos > 0 Then
' Retrieve Control Name from the first part of the string
ProductNameTextCurrent = Left$(ProductNameTextCurrent, intPos - 1)
' MsgBox ProductNameTextCurrent & " " & ProductNameTextPrevious
If ProductNameTextCurrent <> ProductNameTextPrevious Then
ProductNameTextPrevious = ProductNameTextCurrent
Me.ProductSectionName.Value = ProductNameTextCurrent
End If
End If
Next I
I can see the logic working fine. The issue is that it Me.ProductSectionName.Value = ProductNameTextCurrent changes all rows to the current value in ProductNameTextCurrent. I need to be able to specify the row in Me.ProductSectionName.Value but cant see a way to do this?
Many thanks
Tony