Airfield Models - Visual Basic Database

Converting VB DB to a Daily Quote Applet (Stand-Alone Version)

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
(Stand-Alone Version)

Note: This tutorial uses the code resulting from Tutorial 1.

There are several ways to go about turning the Daily Quote into a stand-alone application depending on what features you want the end user to have.

My way of handling this particular task was to remove field definitions editing capabilities from the end user.  I left the record editing capabilities in place so the user can add, edit or delete quotes at his option.

Here's the plan in a nutshell:

  • Remove field definition editing functionality.
  • Open the last used file at startup and automatically display the next quote.

 
 

Step 1 Remove Field Definition Editing Capability

  • Remove frmFieldDefinitions.frm form from the project

  • Remove the mnuRecordsFieldDefinitions menu item using the menu editor.  Remove the separator item (mnuRecordsSeparator5) as well.

  • Delete the mnuRecordsFieldDefinitions_Click sub-routine code in the form.

  • Delete the mnuRecords_Click sub-routine code in the form.

 
 

Step 2 Open the Last Used File at Start-Up

  • Modify the code in the FormLoad event of frmQuote.frm as follows:

Before conversion

' frmQuote.frm

Private Sub Form_Load()

Prompt = True

SetupToolbar
StartDatabase

Set MRU.Form = Me
Set frmFind.frmParent = Me

StatusBar1.Panels("EditMode").Text = "No open database"

End Sub

After conversion

' frmQuote.frm

Private Sub Form_Load()
Dim sFilename As String

Prompt = True

SetupToolbar

Set MRU.Form = Me
Set frmFind.frmParent = Me

StatusBar1.Panels("EditMode").Text = "No open database"

' Open last file on startup
sFilename = GetSetting(App.Title, "Quote", "Last file", vbNullString)

If FileExists(sFilename) Then
 
Filename = sFilename
Else
  Exit Sub
End If

End Sub

 
 

Step 3 Move to the Next Quote

  • Retrieve the index of the last read quote and automatically move to the next quote on start-up.

Before conversion

' frmQuote.frm

Private Sub StartDatabase()
Dim i As Long

If TBL.RecordCount = 0 Then
 
Reposition ADD_NEW
Else
 
Reposition MOVE_FIRST
End If

End Sub

After conversion

' frmQuote.frm

Private Sub StartDatabase()
Dim nRecordNumber As Long

nRecordNumber = GetSetting(App.Title, "Quote", "Last quote", 1)

' Get next quote
nRecordNumber = nRecordNumber + 1

With TBL
  If .RecordCount > 0 Then
    If
nRecordNumber > .RecordCount Then ' Next record is beyond end of file
   
  nRecordNumber = 1
    End If
   
Reposition MOVE_RECORDNUMBER, nRecordNumber
  Else
   
' There are no records
 
End If
End With

End Sub

 
 

Step 4 Save Last Read Quote to Registery on Reposition

  • Save the index position of the record when it is read.

After conversion

' frmQuote.frm

Public Function Reposition(Direction As REPOSITION_TYPE, Optional iRecordNumber As Long) As Long

' Code omitted for brevity

' Add this line to save the last recordnumber to the registry
SaveSetting App.Title, "Quote", "Last quote", TBL.RecordNumber

Exit Function

errHandler:
Dim nErrReturn As Long

nErrReturn = ErrorHandler(Error, Err, TBL.Filename, Me.Name & ".Reposition")

End Function

Notes:

  • You should consider changing the word "Record" in menu captions and toolbar tooltips to the word "Quote."
  • Compile the code into an exe and create your setup package.
 
 

Previous —
Next —

Final Step to Converting VB DB to a Daily Quote Applet (Developer's Version)
Download Visual Basic Database (VB DB) Source Code

Comments about VBDB

 
 

Back to VB DB
Airfield Models Home

 
 

Copyright © 2002-2005 Paul K. Johnson