I have one table in Access with some combo box fields (combo box as row source). each combo box has 2 columns (1st one is integer type and 2nd one is text type). what is visible to the user is the 2nd column. 1st one is the bound column.
If I open the table and type the text related to the list, it doesn't cause any error. What I want to do is to fill the combo box via VBA but, with text, instead of integer number.
In the first combo box, for instance, there are 2 options visible to the user: "C" and "V". "C" in the bound column is 1 and "V" is 2. I need to send the character to the combo box and save it. When I try to enter the text, "Data Type Conversion Error" happens. what can I do, in this case?
Thanks in advance.
Code:
Public Sub SalvarAreaRangeNoBD(registro As DAO.Recordset, areaRange As Range)
Dim totalLin, l As Integer
Dim totalCol, c As Integer
Dim deletar As Boolean
totalLin = areaRange.Rows.Count
totalCol = areaRange.Columns.Count
deletar = True
Call mdlUtil.LimparRegistro(registro)
registro.AddNew
For l = 1 To totalLin
For c = 1 To totalCol
If ((areaRange.Cells(l, c) & "") = "") Then
registro.Fields(c - 1).Value = Empty
Else
registro.Fields(c - 1).Value = areaRange.Cells(l, c)
If (deletar <> False) Then
deletar = False
End If
End If
Next c
If (deletar) Then
registro.CancelUpdate
Else
registro.Update
End If
registro.AddNew
deletar = True
Next l
End Sub