I am learning Access slowly, I know some things and others I don't. We have a Metric system that has some bugs that I need to figure out where they are at and what is causing them, as the person who used to do this, found a better possition somewhere else. So I started with the VBA code from the Form. There is a button on the Form, I press it and it runs this code:
I commented after the code, so it fits in the window here... I need help with understand what they are, the ones with ? I understand that this Sub Routine calls others in different places, so I have made a map of all the /Modules that exists, and I make a list of all the Subs and Functions that exists within module, so that I can follow when my VBA Form code calls them and where they are so that I can refer to them, did I do this right ?
Please help out just to understand this code, and then I'll go from there, and follow the links and examine other calls as I follow this code. I am reading an Access book, so hopefully it will help me out further, am already 1/2 way through it.
Private Sub cmdRecDist_Click()
' Start of Sub Routine: cmdRecDist_Click()
On Error GoTo Err_End
' On error goto line that starts with Err_End and continue from there, skip everything
CursorHourGlass
' Call Sub Routine from /Modules/General
ADOCurrentProjectConnect
' Calls Sub Routine from /Modules/General
PopulateTableRECDISVOL
' Calls Sub Routine from /Modules/RECDISTdata
CalRecNonConv1
' Calls Sub Routine from /Modules/RECDISTdata
CalDisNonConv2
' Calls Sub Routine from /Modules/RECDISTdata
CloseConnection
' Calls Sub Routine from /Modules/General
CursorNormal
' Call Sub Routine from /Modules/General
MsgBox ("Complete")
' Display Message Box with the word: Complete to inform user that Form procedure has ended.
Exit Sub
' Exit Subroutine
Err_End:
' Jump point for Error Handling starts here from GoTo statement above
ErrEndConnect
' Calls Sub Routine ErrEndConnet() below
End Sub
' Sub Routine Ends
Sub ErrEndConnect()
' Start of Sub Routine: ErrEndConnect()
If (cnn.State = adStateOpen) Then
cnn.Close
End If
' If Statement. variable cnn = Public cnn As New ADODB.Connection
' ADO - ActiveX Data Objects, connecting to a DataBase to gain access to data source, .Connection = object. If cnn connection.state = Open, then Close the connection and End If statement.
Set cnn = Nothing
' Set cnn variable to null
If (cnn2.State = adStateOpen) Then
cnn2.Close
End If
' Same as above but using cnn2 variable for ADO connection
Set cnn2 = Nothing
' Set cnn2 variable to null
Close #1
' ????? Close #1 ? what is #1 ?
CursorNormal
' Call Sub Routine from /Modules/General
MsgBox (Err.Description)
' Display Message Box with the Error Description
End Sub
' Sub Routine ends.
------------------------
Thank you for your help, if I made a mistake please show where and explain, thanks!!!
I commented after the code, so it fits in the window here... I need help with understand what they are, the ones with ? I understand that this Sub Routine calls others in different places, so I have made a map of all the /Modules that exists, and I make a list of all the Subs and Functions that exists within module, so that I can follow when my VBA Form code calls them and where they are so that I can refer to them, did I do this right ?
Please help out just to understand this code, and then I'll go from there, and follow the links and examine other calls as I follow this code. I am reading an Access book, so hopefully it will help me out further, am already 1/2 way through it.
Private Sub cmdRecDist_Click()
' Start of Sub Routine: cmdRecDist_Click()
On Error GoTo Err_End
' On error goto line that starts with Err_End and continue from there, skip everything
CursorHourGlass
' Call Sub Routine from /Modules/General
ADOCurrentProjectConnect
' Calls Sub Routine from /Modules/General
PopulateTableRECDISVOL
' Calls Sub Routine from /Modules/RECDISTdata
CalRecNonConv1
' Calls Sub Routine from /Modules/RECDISTdata
CalDisNonConv2
' Calls Sub Routine from /Modules/RECDISTdata
CloseConnection
' Calls Sub Routine from /Modules/General
CursorNormal
' Call Sub Routine from /Modules/General
MsgBox ("Complete")
' Display Message Box with the word: Complete to inform user that Form procedure has ended.
Exit Sub
' Exit Subroutine
Err_End:
' Jump point for Error Handling starts here from GoTo statement above
ErrEndConnect
' Calls Sub Routine ErrEndConnet() below
End Sub
' Sub Routine Ends
Sub ErrEndConnect()
' Start of Sub Routine: ErrEndConnect()
If (cnn.State = adStateOpen) Then
cnn.Close
End If
' If Statement. variable cnn = Public cnn As New ADODB.Connection
' ADO - ActiveX Data Objects, connecting to a DataBase to gain access to data source, .Connection = object. If cnn connection.state = Open, then Close the connection and End If statement.
Set cnn = Nothing
' Set cnn variable to null
If (cnn2.State = adStateOpen) Then
cnn2.Close
End If
' Same as above but using cnn2 variable for ADO connection
Set cnn2 = Nothing
' Set cnn2 variable to null
Close #1
' ????? Close #1 ? what is #1 ?
CursorNormal
' Call Sub Routine from /Modules/General
MsgBox (Err.Description)
' Display Message Box with the Error Description
End Sub
' Sub Routine ends.
------------------------
Thank you for your help, if I made a mistake please show where and explain, thanks!!!