Airfield Models - Visual Basic Database

Converting VB DB to a Daily Quote Applet (Developer's Version) - Step 6

December 19, 2021



Home
About
Site Feedback
Register
Contact
Site Map
Add to Favorites
Comments
Search Airfield Models

Back to VB DB

 

Airfield Models (http://www.airfieldmodels.com/)Converting VB DB to a Daily Quote Applet
(Developer's Version)

Download VB DB Source Code here.

 
 

Step 6 of 7

Now it's time to hook up the controls to the fields we have created.  In the code view for frmDatabase.frm change the code as follows by modifying the GetData sub-routine.

Before conversion

'frmDatabase.frm

Private Function GetData() As Long

' Function populates controls with Record data
' Returns Error value

On Error GoTo errHandler

' ***** MODIFY *****

With Record
  chkBoolean_01.Value = IIf(.Fields(FIELD_01), vbChecked, vbUnchecked)
  txtByte_01.Text = Trim$(CStr(.Fields(FIELD_02)))
  txtDate_01 = .Fields(FIELD_03)
  txtInteger_01.Text = CStr(.Fields(FIELD_05))
  txtLong_01.Text = CStr(.Fields(FIELD_06))
  txtSingle_01.Text = CStr(.Fields(FIELD_07))
  txtString_01.Text = .Fields(FIELD_08)
End With

PopulateArrayList 0

' ***** END MODIFY *****

Exit Function

errHandler:
GetData = Err

End Function

After conversion

' frmDatabase.frm

Private Function GetData() As Long

' Function populates controls with Record data
' Returns Error value

On Error GoTo errHandler

With Record
  txtQuote.Text = CStr(.Fields(QUOTE_TEXT))
  txtAuthor.Text = CStr(.Fields(QUOTE_AUTHOR))
End With

Exit Function

errHandler:
GetData = Err

End Function

Next, modify the SetData sub-routine.

Before conversion

' frmDatabase.frm

Private Function SetData() As Long

' Returns Error value

On Error GoTo errHandler

' ***** MODIFY *****

With Record
  .Fields(FIELD_01) = chkBoolean_01.Value = vbChecked
  .Fields(FIELD_02) = txtByte_01.Text
  .Fields(FIELD_03) = txtDate_01.Text
  .Fields(FIELD_05) = txtInteger_01.Text
  .Fields(FIELD_06) = txtLong_01.Text
  .Fields(FIELD_07) = txtSingle_01.Text
  .Fields(FIELD_08) = txtQuote.Text
End With

' ***** END MODIFY *****

Exit Function

errHandler:
SetData = Err

End Function

After conversion

' frmDatabase.frm

Private Function SetData() As Long

' Returns Error value

On Error GoTo errHandler

With Record
  .Fields(QUOTE_TEXT) = Trim$(txtQuote.Text)
  .Fields(QUOTE_AUTHOR) = Trim$(txtAuthor.Text)
End With

Exit Function

errHandler:
SetData = Err

End Function

Finally, modify the mnuRecordsNewRecord_Click Event.

Before conversion

' frmDatabase.frm

Private Sub mnuRecordsNewRecord_Click()

Reposition ADD_NEW
chkBoolean_01.SetFocus

End Sub

After conversion

' frmDatabase.frm

Private Sub mnuRecordsNewRecord_Click()

Reposition ADD_NEW
txtQuote.SetFocus

End Sub

 
 

Previous —
Next —

Step 5 of Converting VB DB to a Daily Quote Applet (Developer's Version)
Step 7 of Converting VB DB to a Daily Quote Applet (Developer's Version)

Comments about VBDB

 
 

Back to VB DB
Airfield Models Home

 
 

Copyright © 2002-2005 Paul K. Johnson