I need help once more with my sample program. Can't ask a teacher or professor since I am self-studying.

I can't seem to make the textboxes on the right display additional details from my database which isn't shown on the dataGrid.
Here's my code for the current form:
Option Explicit 'variable declaration Dim RS As ADODB.Recordset Dim strSQL As String 'end of declarations Private Sub cmdReload_Click() strSQL = "Select StuNo, LastName, FirstName, MI, Course, Year, Section from tblCS;" Call OpenNewRecordset Call LoadDataOnGrid End Sub Private Sub cmdAlphabetical_Click() strSQL = "Select StuNo, LastName, FirstName, MI, Course, Year, Section from tblCS order by LastName, FirstName;" Call OpenNewRecordset Call LoadDataOnGrid End Sub Private Sub cmdYearSection_Click() strSQL = "Select StuNo, LastName, FirstName, MI, Course, Year, Section from tblCS order by Year, Section, LastName;" Call OpenNewRecordset Call LoadDataOnGrid End Sub Private Sub cmdStuNo_Click() strSQL = "Select StuNo, LastName, FirstName, MI, Course, Year, Section from tblCS order by StuNo;" Call OpenNewRecordset Call LoadDataOnGrid End Sub Private Sub Form_Load() CenterForm Me 'keep form in center Connectonload 'connect dbCS on form load Call cmdReload_Click 'load all data to grid End Sub Private Sub OpenNewRecordset() 'for fast opening of recordset Set RS = New ADODB.Recordset RS.CursorLocation = adUseClient RS.Open strSQL, gCONN, adOpenKeyset, adLockOptimistic, adCmdText 'display current query on txtCurrQuery txtCurrQuery.Text = strSQL End Sub Private Sub LoadDataOnGrid() 'setup datagrid data Set datGridMain.DataSource = RS Exit Sub End Sub
and here are the codes for the module used by the form:
Option Explicit
'declare connection variables
Public gCONN As ADODB.Connection
Public gRS As ADODB.Recordset
Public gStrSQL As String
'end of declarations
Public Sub Connectonload()
'reload connection variables
Set gCONN = New ADODB.Connection
'set gCONN properties
gCONN.ConnectionString = "Driver={MySQL ODBC 3.51 Driver};" _
& "Server=127.0.0.1;" _
& "Database=dbCS;" _
& "User=root;" _
& "Password=root;" _
& "Option=3"
'open connection to database
gCONN.Open
End Sub
Public Sub CenterForm(objForm As Form)
'Center Form
With objForm
.Top = (Screen.Height - .Height) / 2
.Left = (Screen.Width - .Width) / 2
End With
End Sub
I've tried adding a data control and using the settings equal to the module's but I still can't make it work.
Please help me. Any suggestions or advice would be good. I just need hints, but a little spoonfeeding would be nice.
This post has been edited by jcgonz: 13 February 2013 - 01:12 AM

New Topic/Question
Reply



MultiQuote



|