I'm using a MSHFlexGrid (fgdVehicle) to input data from a database ( via a recordset (rsVehicle) ).
You can either enter the data into the database in two ways :

       1. From the database application
       2. From a form.

The problem is present in the second method.
There are specific textboxes (txtID, txtModel, txtChassis and txtCompany) and a combobox (cboType) to enter the data into the certain fields, and when you click on the "Save" button, the data will get saved to the FlexGrid as a new record (also gets saved to the database at the same time).
My problem is, the text entered into the textboxes get saved into the record in the FlexGrid, but the option you select in the combobox of the form won't get shown (that column in the FlexGrid is empty). When I put a break-point and run the code, it shows that the combobox is empty, therefore, nothing is shown in the record for the combobox field.

Here is the code I'm using :

  Dim rsVehicle As New ADODB.Recordset  
  Dim cn As New ADODB.Connection   
  Dim strSQL As String   


  cmdSaveNew.Enabled = True  
  cmdCancel.Visible = True   

  cn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;" & _
                        "Data Source=" & App.Path & "\Luckshan Tours & Travels.mdb;" & _
                        "Persist Security Info:False"                                      

  cn.Open  
  strSQL = "SELECT [Vehicle].* FROM [Vehicle]"   
  rsVehicle.Open strSQL, cn, adOpenStatic, adLockPessimistic   

  If rsVehicle.RecordCount <> 0 Then   
    rsVehicle.MoveLast  
    rsVehicle.AddNew   
    rsVehicle.Fields("Vehicle ID") = txtID   
    rsVehicle.Fields("Vehicle Model") = txtModel   
    rsVehicle.Fields("Chassis No") = txtChassis 
    rsVehicle.Fields("Vehicle Type") = cboType 
    rsVehicle.Fields("Companies Registerd To") = txtCompany   
    If txtID = "" Then  
      msg = MsgBox("Please enter Vehicle ID", vbExclamation, "Error")   
      Exit Sub   
    End If   
  ElseIf rsVehicle.RecordCount = 0 Then  
    rsVehicle.AddNew   
    rsVehicle.Fields("Vehicle ID") = txtID  
    rsVehicle.Fields("Vehicle Model") = txtModel   
    rsVehicle.Fields("Chassis No") = txtChassis
    rsVehicle.Fields("Vehicle Type") = cboType   
    rsVehicle.Fields("Companies Registerd To") = txtCompany dset (rsVehicle).
    If txtID = "" Then   
      msg = MsgBox("Please enter Vehicle ID", vbExclamation, "Error")  
      Exit Sub 
    End If 
  End If 


  rsVehicle.Update   

  cmdBack.Enabled = True   
  cmdDelete.Enabled = True 
  cmdLogOut.Enabled = True  
  cmdUpdate.Enabled = True   
  cmdRefresh.Enabled = True   
  cmdSearch.Enabled = True  
  cmdAdd.Enabled = True   
  Me.cmdSaveNew.Enabled = False  

  msg = MsgBox("Record Saved.", vbInformation, "Notification")   

  cmdCancel.Visible = False   

  Set fgdVehicle.DataSource = rsVehicle   

  rsVehicle.Update  

First error, in row 60 (last) you have rsVehicle.Update again, after you called the update on row 43...

Show me the code where you select the record from database BEFORE setting the datasource of your flexgrid. Your error lies in the selection, you need to show the grid what to display...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.