hello,

when i add a txtbox to a form how does access index this ?

i have the below code that will itterate through the form objects and add the data from the Record set.

The issue i have is when i add a new textbox this then becomes the last indexed object on the form. i have updated the sql so that it wil corispond with the text box however the RS is not corisponding to the SQL

SQL Code:
  1. SELECT tblTechInfo.JobNo, tblTechInfo.ExisitngMeterModel, tblTechInfo.ExistingMeterType, tblTechInfo.ExistingMeterManufacturer, tblTechInfo.ExistingMeterSerialNo, tblTechInfo.IntendedGasUsage, tblTechInfo.HourlyCapacity, tblTechInfo.AdditionalHourlyCapacity, tblTechInfo.TotalHourlyCapacity, tblTechInfo.AQ, tblTechInfo.TypeOfLoad, tblTechInfo.TypeOfSupply, tblTechInfo.InletPressure, tblTechInfo.MeterHousing, tblTechInfo.MeterBase, tblTechInfo.Converter, tblTechInfo.ChatterBox, tblTechInfo.AMR, tblTechInfo.Booster, tblTechInfo.TwinStream, tblTechInfo.ByPass, tblTechInfo.Purge, tblTechInfo.ProposedMeterLocation, tblTechInfo.SpecialistMeterEquip, tblTechInfo.RequiredMeterModel, tblTechInfo.OutletPressure
  2. FROM tblTechInfo
  3. WHERE (((tblTechInfo.JobNo)=1));

VB Code:
  1. For Each ctl In Me.Controls
  2.     If ctl.ControlType = acTextBox Or ctl.ControlType = acComboBox Then
  3.         'debug is used to test the field corisponds with the textbox'
  4.  
  5.         Debug.Print M_RS(i).Name
  6.         Debug.Print ctl.Name
  7.  
  8.         If Not IsNull(M_RS(i)) And Not M_RS.EOF Then
  9.             ctl.Value = M_RS(i)
  10.         End If
  11.         i = i + 1
  12.     End If
  13.    
  14.    
  15. Next
the item prefiexed (txt,cbo)are the form objects
DEBUG output Code:
  1. JobNo
  2. txtJobNo
  3. ExisitngMeterModel
  4. txtExistingMeterModel
  5. ExistingMeterType
  6. cboExisitngMeterType
  7. ExistingMeterManufacturer
  8. cboExisitingMeterMnufacturer
  9. ExistingMeterSerialNo
  10. txtExisitingMeterSerialNo
  11. IntendedGasUsage
  12. cboIntendedGasUsage
  13. HourlyCapacity
  14. txtHourlyCapacitySHQKWCurrent
  15. AdditionalHourlyCapacity
  16. txtHourlyCapacitySHQKWAddiitional
  17. TotalHourlyCapacity
  18. txtHourly CapacitySHQKWTotal
  19. AQ
  20. txtAnualQuantity
  21. TypeOfLoad
  22. cboLoadType
  23. TypeOfSupply
  24. cboSupplyType
  25. InletPressure
  26. cboInlet Presure
  27. MeterHousing
  28. cboProposedMeterLocation
  29. MeterBase
  30. txtSpecialistMeteringEquipment
  31. Converter
  32. cboRequireMeterModel
  33. ChatterBox
  34. txtOutletPresure

My objective is to have outletpresure and txtoutlet presure running one after the other.

can anyone advise why the RS will not corispond with the form objects or how i can re-index the form objects. without using a number to create a control array style form?

thanks in Advance