I have a DataGrid which is bound to an ADODC and it allows updates. The database consists of different tables and the SQL for this ADODC is "SELECT stID, stName, grID, grName FROM tblStudent, tblGroup WHERE tblGroup.grID=tblStudent.stGroup ORDER BY grName, stName". The student's group is referenced to the Group table Key field.
I want to be able to easily assign a student to a group by changing the Group column in the DataGrid. However, it changes the name of the group in tblGroup instead of the Group ID in tblStudent.
I can overcome this by showing stGroup in the datagrid and the user enters the Group code (key) instead of the group name but that is VERY messy!
In an ideal world I would have a combobox in the Group column and the user simply selects the correct group for that student.
Please can anyone help me with this, how to fix it, or suggest a different approach - preferably not msFlexGrid because that looks very complicated since it does not allow updates.
My code is below:
I want to be able to easily assign a student to a group by changing the Group column in the DataGrid. However, it changes the name of the group in tblGroup instead of the Group ID in tblStudent.
I can overcome this by showing stGroup in the datagrid and the user enters the Group code (key) instead of the group name but that is VERY messy!
In an ideal world I would have a combobox in the Group column and the user simply selects the correct group for that student.
Please can anyone help me with this, how to fix it, or suggest a different approach - preferably not msFlexGrid because that looks very complicated since it does not allow updates.
My code is below:
vb Code:
Private Sub FillGrid() Dim sSQL As String sSQL = "SELECT stID, stName, grID, grName FROM tblStudent, tblGroup WHERE tblGroup.grID=tblStudent.stGroup" sSQL = sSQL & " ORDER BY grName, stName" ADOAllocate.RecordSource = sSQL ADOAllocate.CommandType = adCmdText ADOAllocate.Refresh dgAllocate.AllowRowSizing = False dgAllocate.Columns(0).Width = 0 'hide Key row dgAllocate.Columns(1).Width = 2500 dgAllocate.Columns(1).Locked = True 'can't change student name dgAllocate.Columns(2).Width = 0 'hide group code dgAllocate.Columns(3).Width = 900 'Group dgAllocate.ScrollBars = dbgHorizontal End Sub