Visual Basic 6.0 Code Examples and Samples for VB6 and SQL Programming

Hello, all. After you have gotten what you came here for, you might want to drop by The Silent Majority: Why Visual Basic 6 Still Thrives. It's an article at Microsoft. Bottom line? You are not alone, VB6 still continues to be popular.

Surprisingly, employment opportunities still abound for Visual Basic 6.0. A simple search for "VB6" at a job search aggregator site brought up over 400 of them.

About This Code Library...

VB6 and SQL programming code examples.
VB6 and SQL programming code examples. | Source

This extensive page contains debugged Visual Basic 6.0 ( VB6 ) code examples from business applications I have written over the years. You will find standalone blocks of SQL, record set processing, data manipulation (field and character level), and some useful GUI routines. Other items include:

  • All sorts of string functions
  • All sorts of while loops
  • Shell command
  • All sorts of date format and other date functions
  • Message box, msgbox
  • Printing
  • File exists
  • Call command
  • Execute
  • Records delete command
  • Queries
  • Select records
  • Select variables
  • Creating and chaining together subroutines
  • And more

An alternative title for this page might be SQL Code Examples. VB6's ability to integrate SQL is one of its major strengths. There is also VBA relevancy.

You will notice occasional code snippets that have been commented, purpose being to temporarily hide them from from the compiler for whatever reason. Even though temporarily commented, the snippets are also production, debugged code.

This page has over 5,000 words of VB6 code snippets, examples, samples, etc. A lot of the syntax remains eternal in the land of visual basic. Hopefully this code library will serve people well for many years.

To scroll left/right in the code blocks you can:

Use the scroll bar at the end of each module.

Or

Click anywhere on the Visual Basic ( VB ) code and use the left/right arrows.

(If the scroll bar isn’t visible and the code text isn’t sequentially numbered at left, then your computer may have run low on memory and is not displaying this page correctly. For a PC tune-up checklist, you can click here (new window or tab).)

If looking for a particular command, syntax, etc.; the F3 or Ctrl-F browser search function may help.

First, a quick poll. Future visitors will appreciate your response. Code immediately follows.

How would you rate yourself as a VB programmer?

See results without voting

VB6 and SQL Code Library One

Visual Basic 6.0 and SQL Examples

'TO RUN WORD OR ANY OTHER SOFTWARE FROM WITHIN A VISUAL BASIC APPLICATION.

Private Sub cmdDocumentation_Click()
    Dim RetVal
    RetVal = Shell("C:\Program Files\Microsoft Office\Office\WINWORD.EXE XYZ.DOC", 1)
End Sub

Private Sub cmdDBpicture_Click()
    frmDBpicture.Show 1
End Sub

Private Sub cmdTechDoc_Click()
    Dim RetVal
    RetVal = Shell("C:\Program Files\Microsoft Office\Office\WINWORD.EXE XYZtech.DOC", 1)
End Sub

Private Sub cmdUserDoc_Click()
    Dim RetVal
    RetVal = Shell("C:\Program Files\Microsoft Office\Office\WINWORD.EXE XYZuser.DOC", 1)
End Sub
'OBTAINING USER DATE RANGE and
'DATE MANIPULATION CODE

'frmDATERANGE screen
'Notes:
'   Variables declared as public in Module1
'   Public procedures can be found in Module1

Private Sub Form_Load()

    varSTARTDATE = Format(Date, "mm/01/yy")
    varENDDATE = DateAdd("d", -1, DateAdd("m", 1, varSTARTDATE))

    txtSTARTDATE.Text = varSTARTDATE
    txtENDDATE.Text = varENDDATE

End Sub

Private Sub cmdMONTH_Click(Index As Integer)

    varSTARTDATE = CDate(Trim(Str(Index)) + "/01/" + Format(Date, "yy"))
    varENDDATE = CDate(DateAdd("d", -1, DateAdd("m", 1, varSTARTDATE)))

    txtSTARTDATE.Text = varSTARTDATE 'global
    txtENDDATE.Text = varENDDATE 'global

End Sub

Private Sub cmdProceed_Click()

    varDR = True

    varSTARTDATE = CStr(txtSTARTDATE.Text)
    varENDDATE = CStr(txtENDDATE.Text)

    varPROCEED = True
    varCANCEL = False

    Me.Hide

End Sub

Private Sub cmdCancel_Click()

    varDR = False
    varPROCEED = False
    varCANCEL = True

    Unload Me

End Sub
Private Sub cmdPrintReport_Click()
'CREATE DATA AND PRINT REPORT USING A SPECIFIED DATE RANGE

Dim dbs As Database
Dim strSQL As String
Dim TheSelectedMonth As String

'FIRST WE DETERMINE WHAT DATE RANGE THE USER WANTS
varCANCEL = False
frmDATERANGE.Show 1
Me.Refresh

If varCANCEL Then Exit Sub

supervarS = CStr(varSTARTDATE)
supervarE = CStr(varENDDATE)

Set dbs = OpenDatabase(gsDatabase)

'NEXT WE SELECT OUT THOSE RECORDS FROM THE RELEVANT TABLE
'TABLES TEMP X,Y,Z ARE INTERMEDIATE STEP TABLES THE USER CAN VIEW
On Error Resume Next
dbs.Execute "DROP TABLE [TEMPX];"
Err.Clear
    strSQL = "SELECT ACCOUNTNOFLD, DATEFLD INTO TEMPX " _
             & "From THETABLE WHERE " _
             & "(((THETABLE.DATEFLD)>=#" & supervarS & "#)) AND " _
             & "(((THETABLE.DATEFLD)<=#" & supervarE & "#)) AND " _
             & "(THETABLE.ANOTHERFLD) ='N';"
    dbs.Execute (strSQL)

'THEN WE GET MORE DATA FROM ANOTHER TABLE
'BY USING THE IN-COMMON ACCOUNTNOFLD USING JOIN
On Error Resume Next
dbs.Execute "DROP TABLE [TEMPY];"
Err.Clear
    strSQL = "SELECT * INTO TEMPY " _
             & "From ANOTHERTBL INNER JOIN TEMPX ON " _
             & "ANOTHERTBL.ACCOUNTNOFLD=TEMPX.ACCOUNTNOFLD;"
    dbs.Execute (strSQL)

'NEXT WE ADD SOME NEW FIELDS
dbs.Execute ("ALTER TABLE TEMPY ADD COLUMN CUSTSUBSETFLD text")
dbs.Execute ("ALTER TABLE TEMPY ADD COLUMN ORDERSUBSETFLD text")

dbs.Close

'THEN POPULATE FIELDS WITH CUSTSUBSETFLD AND ORDERSUBSETFLD DATA
Set dbs = OpenDatabase(gsDatabase)
Set rstTEMPY = dbs.OpenRecordset("TEMPY")

Me.Refresh
Counter = 1
With rstTEMPY
    .MoveFirst
    While Not .EOF
        .Edit
        If Not IsNull(.THELARGERFLD) Then
            .CUSTSUBSETFLD = CStr(Mid(.THELARGERFLD, 1, 11))
            .ORDERSUBSETFLD = CStr(Mid(.THELARGERFLD, 15, 20))
        Else
            .CUSTSUBSETFLD = "None"
            .ORDERSUBSETFLD = "None"
        End If
        .Update
        Counter = Counter + 1
        Debug.Print CStr(Counter)
        .MoveNext
    Wend
End With

rstTEMPY.Close

'INDEX TABLES SO CRYSTAL REPORTS WILL WORK
dbs.Execute "CREATE INDEX NewIndexX ON TEMPX (ACCOUNTNOFLD);"
dbs.Execute "CREATE INDEX NewIndexY ON TEMPY (ACCOUNTNOFLD);"

dbs.Close
Set rstTEMPY = Nothing
Set dbs = Nothing

'DEFINE REPORT
CR1.ReportFileName = "THEREPORT.rpt"

'PUT REPORT TITLE AND MONTH IN FORMULA FOR CRYSTAL REPORTS TO USE.
'CR1.Formulas(0) = "USERMONTH= " _
                  & "'" & theCurrentMonth & "'"

'RUN REPORT
CR1.Action = 1

Close
Set dbs = Nothing
End Sub 'END OF CREATE DATA AND PRINT REPORT USING A SPECIFIED DATE RANGE
Private Sub cmdAnotherRpt_Click()

Dim dbs As Database
Dim strSQL As String
Dim TheSelectedMonth As String

varCANCEL = False
frmDATERANGE.Show 1
Me.Refresh

If varCANCEL Then Exit Sub

theCurrentMonth = "Blah Blah Report for " _
                  & CStr(Format(varENDDATE, "mmmm"))
thePrevMonthX = DateAdd("m", -1, varENDDATE)
ThePrevMonth = CStr(UCase(CStr(Format(thePrevMonthX, "mmm"))))

Set dbs = OpenDatabase(gsDatabase)

On Error Resume Next
dbs.Execute "DROP TABLE [TEMPX];"
Err.Clear

'Gets the code 2 data WITH THE APPROPRIATE MONTH FIELD
strSQL = "SELECT FLDA, FLDB, FLDC, FLDD, " _
         & ThePrevMonth _
         & " INTO TEMPX From SOURCETABLE " _
         & "WHERE CODE = '2' AND OTHERFLD = 'Y';"
dbs.Execute (strSQL)
        
'create new field for the standard report
dbs.Execute ("ALTER TABLE Tempx ADD COLUMN PrevMonth integer")

'move thePrevMonth to new PrevMonth field
strSQL = "UPDATE TEMPX " _
         & "SET PREVMONTH = " _
         & ThePrevMonth _
         & ";"
    dbs.Execute (strSQL)
    
'PUT NAME OF MONTH IN TABLE FOR CRYSTAL REPORTS TO USE.

CR1.ReportFileName = "THEREPORT.rpt"
CR1.Formulas(0) = "USERMONTH= " _
                  & "'" & theCurrentMonth & "'"
CR1.Action = 1

Close
Set dbs = Nothing

End Sub 'end of cmdAnotherRpt button
Private Sub cmdMonthEndDetailRpt_Click()
'DETAIL REPORT USING MULTIPLE TABLES

Dim dbs As Database
Dim strSQL As String
Dim TheSelectedMonth As String

varCANCEL = False
frmDATERANGE.Show 1
Me.Refresh

If varCANCEL Then Exit Sub

theCurrentMonth = "Month End Detail Report for " _
                  & CStr(Format(varENDDATE, "mmmm"))
thePrevMonthX = DateAdd("m", -1, varENDDATE)
ThePrevMonth = CStr(UCase(CStr(Format(thePrevMonthX, "mmm"))))

Set dbs = OpenDatabase(gsDatabase)

On Error Resume Next
dbs.Execute "DROP TABLE [TEMPX];"
Err.Clear

'Gets INVENFILE data WITH THE APPROPRIATE MONTH FIELD
strSQL = "SELECT SKU, DESC, ISSUEUNIT, VENDOR, CURR_BAL, " _
         & ThePrevMonth _
         & " INTO TEMPX From INVENFILE;"
dbs.Execute (strSQL)
        
'create new field for the standard report
dbs.Execute ("ALTER TABLE Tempx ADD COLUMN PrevMonth integer")

'move thePrevMonth to new PrevMonth field
strSQL = "UPDATE TEMPX " _
         & "SET PREVMONTH = " _
         & ThePrevMonth _
         & ";"
    dbs.Execute (strSQL)
    
'WE'VE CREATED THE TEMPX TABLE THAT CONTAINS THE INVENTORYFILE DATA.
'NOW WE CREATE THE ASSOCIATED TRANSACTION DATA.

supervarS = CStr(varSTARTDATE)
supervarE = CStr(varENDDATE)
    
'WE SELECT OUT THE MTD TRANSACTION RECORDS
On Error Resume Next
dbs.Execute "DROP TABLE [TEMPY];"
Err.Clear
    strSQL = "SELECT SKU, TRANS_NUMBER, ORDERDATE, QTY, THETYPE, TRCODE INTO TEMPY " _
             & "From TRANSACTION WHERE " _
             & "(((TRANSACTION.ORDERDATE)>=#" & supervarS & "#)) AND " _
             & "(((TRANSACTION.ORDERDATE)<=#" & supervarE & "#));"
    dbs.Execute (strSQL)


'NOW WE PLOP IN THE REASON DESCRIPTIONS.

'create new field for the reason description.
dbs.Execute ("ALTER TABLE Tempy ADD COLUMN REASON text")

Set wrkJET = CreateWorkspace("", "admin", "", dbUseJet)
Set dbsCurrent = wrkJET.OpenDatabase(gsDatabase, True)
Set rstTEMPY = dbsCurrent.OpenRecordset("TEMPY")

Me.Refresh

With rstTEMPY
    
    .MoveFirst
    
    While Not .EOF
    
        .Edit
        
    Select Case .theTYPE  'Evaluate WMSCODE.
        
        Case "A1"
            .reason = "(+) Positive Adjustment"
            
        Case "A2"
            If .TRCODE = "62" Then .reason = "(-) Negative Adjustment"
            If .TRCODE = "64" Then .reason = "(-) Broken/Damaged"
            If .TRCODE = "61" Then .reason = "(-) Repackaging Adjustment"
            
        Case "C1"
            .reason = "(+) Customer Return"
            
        Case "M2"
            If .TRCODE = "82" Then .reason = "(-) Issue to Customer"
            If .TRCODE = "80" Then .reason = "(-) Exception Order"
            
        Case "P1"
            .reason = "(+) Repack Finished Stock"
            
        Case "P2"
            .reason = "(-) Repack Bulk Stock"
            
        Case "R1"
            .reason = "(+) Receiving"
            
        Case "R2"
            .reason = "(-) Receiving Adjustment"
            
        Case "V2"
            .reason = "(-) Return to Vendor"
            
        Case "V1"
            .reason = "(+) Exchange from Vendor"
              
        Case Else
            .reason = "Unknown"
            
    End Select
    
    .Update
      
    .MoveNext
    
    Wend
    
End With

rstTEMPY.Close
dbsCurrent.Close
wrkJET.Close
Set rstTEMPY = Nothing
Set dbsCurrent = Nothing
Set wrkJET = Nothing

dbs.Execute "CREATE INDEX NewIndexX ON TEMPX (SKU);"
dbs.Execute "CREATE INDEX NewIndexY ON TEMPY (SKU);"

'DEFINE REPORT
CR1.ReportFileName = "MEDETAIL.rpt"

'PUT REPORT TITLE AND MONTH IN FORMULA FOR CRYSTAL REPORTS TO USE.
CR1.Formulas(0) = "USERMONTH= " _
                  & "'" & theCurrentMonth & "'"

'RUN REPORT
CR1.Action = 1

Close
Set dbs = Nothing
End Sub 'END OF cmdMonthEndDetailRpt
'CODE FOR A MULTIPLE QUERIES FORM

Private Sub cmdClose_Click()
Me.Hide
End Sub

'USE ANOTHER FORM TO GET DATE RANGE
Private Sub cmdDR_Click()
frmDATERANGE.Show
Me.Refresh
End Sub

Private Sub cmdReceipt_Click()
If varRO = "R" Then
    varRO = ""
    cmdReceipt.Caption = "Click for &Receipts Only (TR30 and TR36)"
Else
    varRO = "R"
    cmdReceipt.Caption = "Receipts Only Option Selected"
    cmdOrder.Caption = "Click for &Orders Only   (TR80 and TR82)"
    cmdWorkOrder.Caption = "Click for &Work Orders Only   (TR40)"
    End If
End Sub

Private Sub cmdOrder_Click()
If varRO = "O" Then
    varRO = ""
    cmdOrder.Caption = "Click for &Orders Only   (TR80 and TR82)"
Else
    varRO = "O"
    cmdOrder.Caption = "Orders Only Option Selected"
    cmdReceipt.Caption = "Click for &Receipts Only (TR30 and TR36)"
    cmdWorkOrder.Caption = "Click for &Work Orders Only   (TR40)"
End If
End Sub

Private Sub cmdWorkOrder_Click()
If varRO = "W" Then
    varRO = ""
    cmdWorkOrder.Caption = "Click for &Work Orders Only   (TR40)"
Else
    varRO = "W"
    cmdWorkOrder.Caption = "Work Orders Only Option Selected"
    cmdReceipt.Caption = "Click for &Receipts Only (TR30 and TR36)"
    cmdOrder.Caption = "Click for &Orders Only   (TR80 and TR82)"
End If
End Sub
Private Sub cmdReset_Click()

varRO = ""
    cmdReceipt.Caption = "Click for &Receipts Only (TR30 and TR36)"
    cmdOrder.Caption = "Click for &Orders Only   (TR80 and TR82)"
    cmdWorkOrder.Caption = "Click for &Work Orders Only   (TR40)"
    
varDR = False

varSingleSKU = ""
    txtSKU.Text = ""

varSingleAcctCode = ""
    txtACCOUNTCODE.Text = ""
    
varSinglePOnumber = ""
    txtPOnumber.Text = ""

End Sub

Private Sub cmdSEARCH_click(x)
End Sub

Private Sub cmdSEARCHX_Click()

Dim dbs As Database
Set dbs = OpenDatabase(gsDatabase)

cmdSEARCHX.Caption = "Working..."

'First we select out the user requested date range.

Me.Refresh
On Error Resume Next
dbs.Execute "DROP TABLE [TEMPX];"
Err.Clear

If varDR Then 'get the specified date range

    supervarS = CStr(varSTARTDATE)
    supervarE = CStr(varENDDATE)
    
    strSQL = "SELECT * INTO TEMPX " _
        & "From TRANSACTION WHERE " _
        & "(((TRANSACTION.THEDATE)>=#" & supervarS & "#)) AND " _
        & "(((TRANSACTION.THEDATE)<=#" & supervarE & "#));"
    dbs.Execute (strSQL)

Else 'make copy of entire transaction file
    
    strSQL = "SELECT * INTO TEMPX From TRANSACTION;"
    dbs.Execute (strSQL)
    
End If

'Next we check if user wants Receipt-Only, Orders-Only, Work Orders-Only or all.

On Error Resume Next
dbs.Execute "DROP TABLE [TEMPY];"
Err.Clear

If varRO = "R" Then 'get receipts only

    strSQL = "SELECT * INTO TEMPY " _
        & "From TEMPX WHERE " _
        & "TEMPX.TRCODE = '30' OR TEMPX.TRCODE = '36';"
    dbs.Execute (strSQL)

Else
End If

If varRO = "O" Then 'get orders only

    strSQL = "SELECT * INTO TEMPY " _
        & "From TEMPX WHERE " _
        & "TEMPX.theTYPE = 'M2' OR TEMPX.theTYPE = 'M3';"
    dbs.Execute (strSQL)

Else
End If

If varRO = "W" Then 'get work orders only

    strSQL = "SELECT * INTO TEMPY " _
        & "From TEMPX WHERE " _
        & "TEMPX.TRCODE = '40';"
    dbs.Execute (strSQL)

Else
End If

If varRO = "" Then 'keep everything
    strSQL = "SELECT * INTO TEMPY From TEMPX;"
    dbs.Execute (strSQL)
Else
End If

'We've taken care of the dateRange and the R vs O scenarios
'Next let's do the Single Account

On Error Resume Next
dbs.Execute "DROP TABLE [TEMPZ];"
Err.Clear

If txtACCOUNTCODE.Text = "" Then 'user doesn't want a single account
    strSQL = "SELECT * INTO TEMPZ From TEMPY;"
    dbs.Execute (strSQL)
Else 'user wants data only for a single account
    varSingleAcctCode = CStr(txtACCOUNTCODE.Text)
    strSQL = "SELECT * INTO TEMPZ " _
        & "From TEMPY WHERE " _
        & "(((TEMPY.ACCTCODE)='" & varSingleAcctCode & "'));"
    dbs.Execute (strSQL)
End If

'Now let's do the single P.O.

On Error Resume Next
dbs.Execute "DROP TABLE [TEMPX];"
Err.Clear

If txtPOnumber.Text = "" Then 'user doesn't want a single P.O. number
    strSQL = "SELECT * INTO TEMPX From TEMPZ;"
    dbs.Execute (strSQL)
Else 'user wants data only for a P.O.
    varSinglePOnumber = CStr(txtPOnumber.Text)
    strSQL = "SELECT * INTO TEMPX " _
        & "From TEMPZ WHERE " _
        & "(((TEMPZ.PO_NUMBER)='" & varSinglePOnumber & "'));"
    dbs.Execute (strSQL)
End If

'Last is the single SKU scenario,
'this calls for a different output than the rest
If txtSKU.Text = "" Then 'processing is done, show output to user
    frmX.Show
Else 'this is the single SKU scenario, processing continues
    'first we get the records for the requested SKU
    On Error Resume Next
    dbs.Execute "DROP TABLE [TEMPY];"
    Err.Clear
    varSingleSKU = CStr(txtSKU.Text)
    strSQL = "SELECT * INTO TEMPY " _
        & "From TEMPX WHERE " _
        & "(((TEMPX.SKU)='" & varSingleSKU & "'));"
    dbs.Execute (strSQL)
    'next we get the SKU description, etc. data
    On Error Resume Next
    dbs.Execute "DROP TABLE [TEMPZ];"
    Err.Clear
    strSQL = "SELECT * INTO TEMPZ " _
             & "From TEMPY INNER JOIN THESKUFILE ON " _
             & "TEMPY.SKU=THESKUFILE.SKU;"
    dbs.Execute (strSQL)
    frmZ.Show
End If
 
endOfJobHK:
cmdSEARCH.Caption = "Search and Display Results"
dbs.Close
Set dbs = Nothing
End Sub

Private Sub Form_Load()
varRO = ""
    cmdReceipt.Caption = "Click for &Receipts Only (TR30 and TR36)"
    cmdOrder.Caption = "Click for &Orders Only   (TR80 and TR82)"
    cmdWorkOrder.Caption = "Click for &Work Orders Only   (TR40)"

varDR = False

varSingleSKU = ""
    txtSKU.Text = ""

varSingleAcctCode = ""
    txtACCOUNTCODE.Text = ""
    
varSinglePOnumber = ""
    txtPOnumber.Text = ""

End Sub 'END OF CODE FOR A QUERIES FORM
Private Sub cmdOPTIMIZE_Click() 'COMPACT THE ACCESS DATABASE ----------------------------------

Dim tempvar As String
Dim tempvarX As String
Dim fileName As String
Dim dirFileName As String
Dim SourceFile, DestinationFile

Close
Set dbs = Nothing
Set SourceFile = Nothing
Set DestinationFile = Nothing
'Set status bar.
    With sbStatusBar
      'This text will be displayed when the StatusBar is in Simple style.
       .Style = sbrNormal  ' Normal style.
       .SimpleText = "Working..."
       .Style = sbrSimple  ' Simple style.
       Refresh
    End With

'Create backup file name.
    tempvar = "XX"
    tempvarX = Trim(Str(Format(Date, "mmddyy")))
    fileName = tempvar + tempvarX + ".mdb"
    dirFileName = "XXXBU\" + fileName
        
'Make sure there isn't already a file with the name of the compacted database.
    On Error GoTo errorRTN2
    If Dir(dirFileName) <> "" Then Kill dirFileName
    
'Makes temp backup before optimization.
    On Error GoTo errorRTN2
    If Dir("tempBU.mdb") <> "" Then Kill "tempBU.mdb"
    SourceFile = "XXX.mdb"          'Define source file name.
    DestinationFile = "tempBU.mdb"  'Define target file name.
    On Error GoTo errorRTN2
    FileCopy SourceFile, DestinationFile    ' Copy source to target.

'Compacts (optimizes) the database.
    On Error GoTo errorRTN2
    DBEngine.CompactDatabase "XXX.mdb", dirFileName
    
'Copies optimized database over the original.
    On Error GoTo errorRTN2
    If Dir("XXX.mdb") <> "" Then Kill "CST.mdb"
    SourceFile = dirFileName        'Define source file name.
    DestinationFile = "XXX.mdb"     'Define target file name.
    On Error GoTo errorRTN2
    FileCopy SourceFile, DestinationFile    ' Copy source to target.
    MsgBox ("Database optimized and a " + dirFileName + " backup copy made.")

Close
tempvar = ""
tempvarX = ""
fileName = ""
dirFileName = ""
Set SourceFile = Nothing
Set DestinationFile = Nothing

Exit Sub

errorRTN2:
    MsgBox ("File conflict problem.  Exit/Restart application and try again.")

End Sub 'END OF OPTIMIZE/COMPACT PROGRAM
Private Sub cmdBACKUPdatabase_Click() 'BACKUP THE DATABASE -------------------------------------

Dim tempvar As String
Dim tempvarX As String
Dim fileName As String
Dim dirFileName As String
Dim SourceFile, DestinationFile

Close
tempvar = ""
tempvarX = ""
fileName = ""
dirFileName = ""

Set dbs = Nothing
Set SourceFile = Nothing
Set DestinationFile = Nothing

'Set status bar.
    With sbStatusBar
      ' This text will be displayed when the StatusBar is in Simple style.
       .Style = sbrNormal  ' Normal style.
       .SimpleText = "Working..."
       .Style = sbrSimple  ' Simple style.
       Refresh
    End With
   
'Create backup file name.
    tempvar = "XX"
    tempvarX = Trim(Str(Format(Date, "mmddyy")))
    fileName = tempvar + tempvarX + ".mdb"
    dirFileName = "XXBU\" + fileName
    
'Make sure there isn't already a file with the name of the backup file.
    If Dir(dirFileName) <> "" Then Kill dirFileName

' Make the Backup.
    SourceFile = "XX.mdb"             'Define source file name.
    DestinationFile = dirFileName      'Define target file name.
    On Error GoTo errorRTN
    FileCopy SourceFile, DestinationFile    ' Copy source to target.

    Me.sbStatusBar.Style = sbrNormal  ' Normal style.
    MsgBox ("A Backup copy named " + dirFileName + " has been made.")

Close
tempvar = ""
tempvarX = ""
fileName = ""
dirFileName = ""
Set SourceFile = Nothing
Set DestinationFile = Nothing
'Me.Hide
'Me.Show

Exit Sub

errorRTN:
    MsgBox ("File conflict problem.  Exit/Restart application and try again.")
    
End Sub 'END OF DATABASE BACKUP PROGRAM
'=======================================================
'PRINT FORM CODE
Private Sub cmdPrintScreen_Click()
    Me.PrintForm
End Sub
'=======================================================
'EXIT APPLICATION CODE
Private Sub cmdEXIT_Click() 'EXIT APPLICATION 
    End
End Sub 'END OF EXIT AP
'=======================================================
'LOGIN AND PASSWORD CODE
'Use Wizard
'=======================================================

VB6 and SQL Code Library Two

Chaining Together Subroutines and More Visual Basic 6.0 and SQL Examples

Private Sub cmdWMSupdate_Click() 'CHAINING TOGETHER SUBROUTINES, ETC.

    Dim Uchoice As Integer
    
    XX = Trim(InputBox("Please enter date.", "THE TARGET DATE", "mm/dd/yy"))
    If XX <> "" And XX <> "mm/dd/yy" Then
        theLatestDate = CDate(XX)
    Else
        MsgBox ("Invalid Date. Process cancelled.")
        varCANCEL = True
        GoTo NeverMind
    End If
        
    theEarliestDate = DateAdd("d", -1, Format(theLatestDate, "mm") + "/01/" + Format(theLatestDate, "yy"))

    varSTARTDATE = CDate(theEarliestDate) 'global save for later use.
    varENDDATE = CDate(theLatestDate) 'global save for later use.
 
    
    Uchoice = MsgBox("Please insert the PCfile.txt disk into drive A:", vbOKCancel)
    Me.Refresh
    If Uchoice = 2 Then
        Uchoice = MsgBox("No disk, but will update database totals.", vbOKCancel)
        If Uchoice = 2 Then
            GoTo NeverMind  'ie: bail out of this procedure
        Else
            GoTo JustUpdateTotals
        End If
    Else
        'Proceed...
        varCANCEL = False
        varPROCEED = True
    End If
    
    Me.Refresh
    theMSG = "Emptying old data from TEMPUP table."
    With sbStatusBar
        'This text will be displayed when the StatusBar is in Simple style.
        .Style = sbrNormal  ' Normal style.
        .SimpleText = theMSG
        .Style = sbrSimple  ' Simple style.
    End With
    Me.Refresh
    Call cmdWMSupdate1  'EMPTY'S TEMPUP TABLE
    
    theMSG = "Importing data from diskette in A:drive."
    With sbStatusBar
        'This text will be displayed when the StatusBar is in Simple style.
        .Style = sbrNormal  ' Normal style.
        .SimpleText = theMSG
        .Style = sbrSimple  ' Simple style.
    End With
    Me.Refresh
    Call cmdWMSupdate2 '  IMPORTS DISKETTE DATA INTO TEMPUP

    If varCANCEL Then  '  INVALID DATE.
        MsgBox ("Invalid Date. Process cancelled.")
        GoTo NeverMind
    Else
    End If
    
    theMSG = "Checking for duplicate records."
    With sbStatusBar
        'This text will be displayed when the StatusBar is in Simple style.
        .Style = sbrNormal  ' Normal style.
        .SimpleText = theMSG
        .Style = sbrSimple  ' Simple style.
    End With
    Me.Refresh
    Call cmdWMSupdate3 'CHECK FOR DUPLICATE RECORDS

    If varCANCEL Then  'THERE WERE DUPS OR USER CANCELED FOR SOME REASON.
        MsgBox ("Process canceled.")
        GoTo NeverMind
    Else
    End If

    theMSG = "Doing this, that, and the other in the TEMPUP table."
    With sbStatusBar
        'This text will be displayed when the StatusBar is in Simple style.
        .Style = sbrNormal  ' Normal style.
        .SimpleText = theMSG
        .Style = sbrSimple  ' Simple style.
    End With
    Me.Refresh
    Call cmdWMSupdate4  'MAKES ALL THE SPECIFIED CHANGES IN TEMPUP
                        'AND CHECKS FOR NEW SKU'S.
    
    If varCANCEL Then
        GoTo NeverMind 'THERE ARE MISSING SKU NUMBERS
    Else
    End If
    
    theMSG = "Data review mode."
    With sbStatusBar
        'This text will be displayed when the StatusBar is in Simple style.
        .Style = sbrNormal  ' Normal style.
        .SimpleText = theMSG
        .Style = sbrSimple  ' Simple style.
    End With
    Me.Refresh

'    Call cmdWMSupdateShow '  VIEWS IMPORTED/PROCESSED TEMPUP.
'
'    'USER GIVEN CHANCE TO BAIL OUT BEFORE MERGING DATA WITH PRODUCTION FILES
'    Uchoice = MsgBox("Ready to merge with Production Files.  Continue?", vbYesNoCancel, "Decision Point")
'    If Uchoice <> "6" Then '"6" means "yes"
'        MsgBox ("Process canceled. Production files still not touched.")
'        GoTo NeverMind
'    End If
 
    theMSG = "Updating production files."
    With sbStatusBar
        'This text will be displayed when the StatusBar is in Simple style.
        .Style = sbrNormal  ' Normal style.
        .SimpleText = theMSG
        .Style = sbrSimple  ' Simple style.
    End With
    Me.Refresh
    Call cmdWMSupdate5 'TRANSFER DATA FROM TEMPUP TO PRODUCTION

JustUpdateTotals:

    Call cmdWMSupdate6 'UPDATE SKU FILE QUANTITY TOTALS

    MsgBox ("Production files updated.")

NeverMind:
    With sbStatusBar
        .Style = sbrNormal  ' Normal style.
    End With
    Close
    Me.Refresh

End Sub 'END OF MAIN IMPORT PROGRAM THAT CALLS ALL THE OTHER RELATED SUBPROGRAMS.
Private Sub cmdWMSupdate1() 'EMPTY TEMPUP TABLE ------------------------------------------------
    
Dim dbs As Database

Set dbs = OpenDatabase(gsDatabase)

dbs.Execute "DELETE * FROM TEMPUP;"
    
dbs.Close

Set dbs = Nothing
 
End Sub 'END OF EMPTY TEMPUP TABLE PROGRAM.
Private Sub cmdWMSupdate2() 'Import text data from disk in A:drive into the TEMPUP table.------

Dim theRecord As Record  ' "Record" defined in DECLARATIONS section of MODULE1.bas
Dim theRecNo As Integer

Open "A:\PCFILE.TXT" For Random As #1 Len = Len(theRecord) + 2
theRecNo = 1

'    Record 'Description of record content
'    theTYPE As String * 2
'    SKU As String * 6
'    QTY As String * 5
'    PO_NUMBER As String * 10
'    VEND As String * 4
'    XYZ_NUMBER As String * 24
'    ABCNO As String * 10
'    theDATE As String * 8
'    VVV_NUMBER As String * 11
'    TRCODE As String * 2
'    SCRAP As String * 174

Set wrkJET = CreateWorkspace("", "admin", "", dbUseJet)
Set dbsCurrent = wrkJET.OpenDatabase(gsDatabase, True)
Set rstTEMPUP = dbsCurrent.OpenRecordset("tempup")

Do While Not EOF(1) ' Loop until end of file.
    Get #1, theRecNo, theRecord
    With rstTEMPUP
        If theRecord.SKU > "111" Or theRecord.theTYPE > "a" Then
            .AddNew
            .theTYPE = theRecord.theTYPE
            .SKU = theRecord.SKU
            .QTY = theRecord.QTY
            .PO_NUMBER = theRecord.PO_NUMBER
            .VEND = theRecord.VEND
            .XYZ_NUMBER = theRecord.XYZ_NUMBER
            .ABCNO = theRecord.ABCNO
            .theDATE = varENDDATE
            .Update
        Else
        End If
    End With
    theRecNo = theRecNo + 1
Loop

'With rstTEMPUP
'    .MoveLast
'    If .SKU < "111" Or .theTYPE < "a" Then
'        .Edit      'Gets rid of
'        .Delete    'blank record at end
'        .MovePrevious
'    Else
'    End If
'End With

'With rstTEMPUP
'    .MoveLast
'    If .SKU < "111" Or .theTYPE < "a" Then
'        .Edit      'Gets rid of
'        .Delete    'blank record at end
'        .MovePrevious
'    Else
'    End If
'End With

Close #1            ' Close text file.
    
rstTEMPUP.Close     ' Close Access file.
dbsCurrent.Close    ' Close Access database.
wrkJET.Close
Set rstTEMPUP = Nothing
Set dbsCurrent = Nothing
Set wrkJET = Nothing

NeverMind:

End Sub 'END OF IMPORT TEXT DATA INTO TEMPUP
Private Sub cmdWMSupdate3() 'CHECK FOR DUPS ---------------------------------------------------

    Dim dbs As Database
    Dim supervar As Date
    Dim strSQL As String
    Dim rst As Recordset
    
Set dbs = OpenDatabase(gsDatabase)
    
'do some insurance cleanup, sometimes drop table doesn't work
On Error Resume Next
dbs.Execute "DELETE * FROM TRANSDUPCHECK;"
Err.Clear
On Error Resume Next
dbs.Execute "DELETE * FROM TRANSDUPCHECK2;"
Err.Clear
On Error Resume Next
dbs.Execute "DELETE * FROM DUPSLIST;"
Err.Clear

dbs.Close
Set dbs = Nothing
Set dbs = OpenDatabase(gsDatabase)
   
    supervar = varSTARTDATE
    
    'FIRST WE SELECT OUT THE MTD TRANSACTION RECORDS
    On Error Resume Next
    dbs.Execute "DROP TABLE [TRANSDUPCHECK];"
    Err.Clear
    
    strSQL = "SELECT XXX_NUMBER, SKU, QTY INTO TRANSDUPCHECK " _
             & "From TRANSACTION WHERE " _
             & "(((TRANSACTION.THEDATE)>#" & supervar & "#)) AND " _
             & "(TRANSACTION.TRCODE) <>'40';"
    dbs.Execute (strSQL)

    'NEXT WE SELECT OUT THE SAME THREE CHECK FIELDS FROM TEMPUP
    On Error Resume Next
    dbs.Execute "DROP TABLE [TRANSDUPCHECK2];"
    Err.Clear

    strSQL = "SELECT XXX_NUMBER, SKU, QTY INTO TRANSDUPCHECK2 " _
             & "From TEMPUP WHERE TRCODE <>'40';"
    dbs.Execute (strSQL)
        
    'NEXT WE COMBINE THE TWO TABLES INTO ONE
    strSQL = "INSERT INTO TRANSDUPCHECK " _
             & "SELECT * FROM TRANSDUPCHECK2;"
    dbs.Execute (strSQL)
    
    'NOW WE CHECK FOR DUPLICATE RECORDS AND PUT DUPLICATES IN DUPLIST TABLE.
    On Error Resume Next
    dbs.Execute "DROP TABLE [DUPSLIST];"
    Err.Clear

    strSQL = "SELECT DISTINCTROW " _
             & "First(TRANSDUPCHECK.XXX_NUMBER) AS [XXX_NUMBER Field], " _
             & "First(TRANSDUPCHECK.SKU) AS [SKU Field], " _
             & "First(TRANSDUPCHECK.QTY) AS [QTY Field], " _
             & "Count(TRANSDUPCHECK.XXX_NUMBER) AS NumberOfDups " _
             & "INTO DUPSLIST From TRANSDUPCHECK " _
             & "GROUP BY TRANSDUPCHECK.XXX_NUMBER, " _
             & "TRANSDUPCHECK.SKU, TRANSDUPCHECK.QTY " _
             & "HAVING (((Count(TRANSDUPCHECK.XXX_NUMBER))>1) " _
             & "AND ((Count(TRANSDUPCHECK.QTY))>1));"
    dbs.Execute (strSQL)

    'GIVE USER CHANCE TO VIEW DUPS (IF ANY).

    With dbs
        ' Open table-type Recordset and show RecordCount
        ' property.
        Set rst = .OpenRecordset("DUPSLIST")
        If rst.RecordCount > 0 Then
            On Error Resume Next
            Call cmdWMSduplicateShow
            Err.Clear
        Else
        End If
        On Error Resume Next
        rst.Close
        Err.Clear
   End With

    
NeverMind3:
Close
Set dbs = Nothing

End Sub 'END OF DUPLICATES SEARCH
Private Sub cmdWMSupdateShow() ' GIVE USER CHANCE TO VIEW TEMPUP AND BAIL OUT IF NEEDED. ------

    Dim f As New frmTEMPUP
    Dim ff As New frmDataGrid
    f.Show
    Set ff.Data1.Recordset = f.Data1.Recordset
    ff.Caption = "Processed TEMPUP(pcfile.txt) data"
    ff.Show 1
    ff.Hide
    f.Hide
    
End Sub 'TEMPUP FORM
Private Sub cmdWMSduplicateShow() 'GIVES USER VIEW OF DUPLICATES

    Dim f As New frmDUPLIST
    Dim ff As New frmDataGrid
    f.Show
    Set ff.Data1.Recordset = f.Data1.Recordset
    ff.Caption = f.Caption
    ff.Show 1
    ff.Hide
    f.Hide
    f.Show 1
    f.Hide
    Unload f
    Unload ff
    
End Sub 'DUPLIST FORM SHOWING DUPSFOUND TABLE
Private Sub cmdWMSupdate4() '  MAKES ALL THE SPECIFIED CHANGES IN TEMPUP ----------------------

Dim thedate As Date
Dim IBmsg As String
Dim IBtitle As String
Dim IBdefault As String

ICSdate = varENDDATE 'SETS XXX DATE FROM EARLIER USER INPUT.

Set wrkJET = CreateWorkspace("", "admin", "", dbUseJet)
Set dbsCurrent = wrkJET.OpenDatabase(gsDatabase, True)
Set rstTEMPUP = dbsCurrent.OpenRecordset("TEMPUP")
Set rstSKU = dbsCurrent.OpenRecordset("THEGFILE")

theMSG = "Modifying the TEMPUP table with all the changes,fixes, etc."
    With sbStatusBar
        'This text will be displayed when the StatusBar is in Simple style.
        .Style = sbrNormal  ' Normal style.
        .SimpleText = theMSG
        .Style = sbrSimple  ' Simple style.
    End With
    Me.Refresh

Counter = 0

With rstTEMPUP
    
    .MoveFirst
    
    While Not .EOF
        Counter = Counter + 1
        Debug.Print CStr(Counter)
        .Edit
        
        'PUTS THE PROC DATE IN DATE FIELD.
        .theDATE = xxxdate
   
        'UPDATES ALL TYPE XYZ ORDERS TO CODE 80.
        If .theTYPE = "M2" And Mid(.XXX_NUMBER, 19, 1) <> "1" Then
            .TRCODE = "80"
        End If
        
        'UPDATES the M2 RECORDS WITH CODE "82".
        If .theTYPE = "M2" And Mid(.XXX_NUMBER, 19, 1) = "1" Then
            .TRCODE = "82"
        End If
        
        'EXTRACTS ACCOUNT CODE AND UPDATES M2 RECORDS.
        If .theTYPE = "M2" And IsNull(.ACCTCODE) Then
           .ACCTCODE = Left(.XXX_NUMBER, 13)
        Else
        End If
            
        'UPDATES THE RECEIVING RECORDS TO CODES 30 AND 36.
        If .theTYPE = "R1" Then
            .TRCODE = "30"
        End If
        If .theTYPE = "R2" Then
            .TRCODE = "36"
        End If
        
        'UPDATES THE WORKORDERS TO CODE 40
        If .theTYPE = "P1" Or .theTYPE = "P2" Then
            .TRCODE = "40"
        End If
            
        'UPDATES THE WORKORDER'S WORKORDER# FROM THE WWW NUMBER FIELD.
        If .TRCODE = "40" Then
            .wo_number = Trim(.WWW_NUMBER)
            .WWW_NUMBER = Null
        Else
        End If
        
        'UPDATES THE CLAIM CODE
        If .theTYPE = "C1" Or .theTYPE = "C2" Then
            .TRCODE = "50"
            .ACCTCODE = Trim(.XXX_NUMBER)
            .XXX_NUMBER = Null
        Else
        End If
        
        'CODE 62 ADJUSTMENTS
        If .theTYPE = "A1" Or .theTYPE = "A2" Then
            .TRCODE = "62"
        Else
        End If
        
        'V2 update
        If theTYPE = "V2" Then
            .TRCODE = "72"
        Else
        End If
        
        'V1 update
        If theTYPE = "V1" Then
            .TRCODE = "75"
        Else
        End If
        
        
        'CHECK FOR ANY NEW SKU'S.
         SKUtransVar = Trim(CStr(.SKU))
         'strCountry = "Country = '" & strCountry & "'"
        With rstSKU
                .Index = "PrimaryKey"
                .Seek "=", SKUtransVar
                If .NoMatch Then
                    theMSGX = "SKU " + CStr(SKUtransVar) + " NOT FOUND! UPDATE SKUFILE FILE AND RERUN PROGRAM."
                    MsgBox (theMSGX)
                    varCANCEL = True
                Else
                End If
         End With
        .Update
        .MoveNext
        If varCANCEL Then
            GoTo theNext
        End If
    Wend
End With

theNext:
rstTEMPUP.Close
rstSKU.Close
dbsCurrent.Close
wrkJET.Close
Set rstTEMPUP = Nothing
Set rstSKU = Nothing
Set dbsCurrent = Nothing
Set wrkJET = Nothing

End Sub 'END OF UPDATING TRCODES AND CHECKING FOR MISSING(NEW) SKU'S
Private Sub cmdWMSupdate5() 'TRANSFER DATA FROM TEMPUP TO:-------------------------------------
                            'TRANSACTION AND QQQ FILES -----------------------------------
                            'PUT VEND NUMBER FROM SKU FILE INTO TRANSACTION FILE --------------

Dim Counter As Integer

'OPEN DATABASE AND TABLES
Set wrkJET = CreateWorkspace("", "admin", "", dbUseJet)
Set dbsCurrent = wrkJET.OpenDatabase(gsDatabase)

Set rstTEMPUP = dbsCurrent.OpenRecordset("TEMPUP")
Set rstTRANSACTION = dbsCurrent.OpenRecordset("TRANSACTION")
Set rstMANFILE = dbsCurrent.OpenRecordset("PPPFILE")
Set rstCUSTOMER = dbsCurrent.OpenRecordset("CUSTOMER")
Set rstTRANCODE = dbsCurrent.OpenRecordset("TRANCODE")
Set rstVENDOR = dbsCurrent.OpenRecordset("VENDOR")
Set rstSKU = dbsCurrent.OpenRecordset("SKUFILE")

'FIRST WE TRANSFER TEMPUP DATA TO TRANSACTION

'On Error GoTo theNext
Counter = 0
With rstTEMPUP
    .MoveFirst
    While Not .EOF
        Counter = Counter + 1
        'FIRST WE TRANSFER TEMPUP DATA TO TRANSACTION TABLE
        rstTRANSACTION.MoveLast
        rstTRANSACTION.Edit
        rstTRANSACTION.AddNew
        rstTRANSACTION.XXX_NUMBER = .XXX_NUMBER
        rstTRANSACTION.PPP = .PPPNO
        rstTRANSACTION.SKU = .SKU
        rstTRANSACTION.QTY = .QTY
        rstTRANSACTION.ZZZDATE = .theDATE
        rstTRANSACTION.theTYPE = .theTYPE
        rstTRANSACTION.QQQ_NUMBER = .QQQ_NUMBER
        rstTRANSACTION.TRCODE = .TRCODE
        rstTRANSACTION.VEND = .VEND
        rstTRANSACTION.ACCTCODE = .ACCTCODE
        rstTRANSACTION.wo_number = .wo_number
        rstTRANSACTION.PO_NUMBER = .PO_NUMBER
        'NEXT WE FIGURE OUT THE VEND NUMBER AND
        'PLUG IT INTO THE TRANSACTION FILE
        If rstTRANSACTION.VEND < "1" Then
            SKUtransVar = Trim(CStr(rstTRANSACTION.SKU))
            With rstSKU
                .Index = "PrimaryKey"
                .Seek "=", SKUtransVar
                '.FindFirst SKUtransVar
                If .NoMatch Then
                    MsgBox ("SKU STILL NOT FOUND! VENDOR SET TO 9999.")
                    rstTRANSACTION.VEND = "9999"
                Else
                    rstTRANSACTION.VEND = Trim(CStr(.VENDOR))
                End If
            End With
        Else
        End If
        rstTRANSACTION.Update
        .MoveNext
    Wend
End With

rstTEMPUP.Close     ' Close files.
rstTRANSACTION.Close
rstVVVFILE.Close
rstCUSTOMER.Close
rstTRANCODE.Close
rstVENDOR.Close
rstSKU.Close
Set rstTEMPUP = Nothing
Set rstTRANSACTION = Nothing
Set rstEEEFILE = Nothing
Set rstCUSTOMER = Nothing
Set rstTRANCODE = Nothing
Set rstVENDOR = Nothing
Set rstSKU = Nothing

'LAST WE TRANSFER SAME TEMPUP DATA TO OTHERFILE
    strSQL = "INSERT INTO OTHERFILE " _
             & "(XNO, YDATE) " _
             & "SELECT DISTINCT " _
             & "TEMPUP.XNO, TEMPUP.YDATE " _
             & "FROM TEMPUP WHERE " _
             & "(((TEMPUP.XNO) Is Not Null));"
    dbsCurrent.Execute (strSQL)
    
theNext:
'Err.Clear

dbsCurrent.Close    ' Close database.
wrkJET.Close
Set dbsCurrent = Nothing
Set wrkJET = Nothing

End Sub 'END OF MOVING TEMPUP DATA TO TRANSACTION AND OTHERFILE, AND MOVING SKU VEND TO TRANSACTION
Private Sub cmdWMSupdate6() 'UPDATE SKU TOTALS ------------------------------------------------

    Dim dbs As Database
    Dim supervar As Date
    Dim strSQL As String
    
    Set dbs = OpenDatabase(gsDatabase)
    
thePrevMonthX = DateAdd("m", -1, varENDDATE)
ThePrevMonth = CStr(UCase(CStr(Format(thePrevMonthX, "mmm"))))
    
    On Error Resume Next
    dbs.Execute "DROP TABLE [TEMPX];"
    Err.Clear
    On Error Resume Next
    dbs.Execute "DROP TABLE [TEMPY];"
    Err.Clear

    supervar = varSTARTDATE

    'FIRST WE SELECT OUT THE MTD TRANSACTION RECORDS
    strSQL = "SELECT THEDATE, theTYPE, SKU, QTY INTO TEMPX " _
             & "From TRANSACTION WHERE " _
             & "(((TRANSACTION.THEDATE)>#" & supervar & "#));"
    dbs.Execute (strSQL)
    
    'NEXT WE CONVERT ALL THE INVENTORY REDUCTION
    'TRANSACTIONS QTY'S TO NEGATIVE NUMBERS.
    strSQL = "UPDATE TEMPX " _
             & "SET QTY = QTY*(-1) " _
             & "WHERE MID(theTYPE,2,1) = 2;"
    dbs.Execute (strSQL)
    
    'NEXT WE ADD UP ALL THE QTYS PER SKU.
    strSQL = "SELECT DISTINCTROW TEMPX.SKU, " _
             & "SUM(TEMPX.QTY) AS [QTYTTLS] " _
             & "INTO TEMPY " _
             & "FROM TEMPX GROUP BY TEMPX.SKU;"
    dbs.Execute (strSQL)
    
    'reset current balance to start of month
   strSQL = "UPDATE SKUFILE " _
         & "SET CURR_BAL = " _
         & ThePrevMonth _
         & ";"
    dbs.Execute (strSQL)
    
    'LAST WE ADD THESE TOTALS TO THE SKU CURRENT BALANCE.
    strSQL = " UPDATE SKUFILE LEFT JOIN " _
             & "TEMPY ON SKUFILE.SKU = TEMPY.SKU " _
             & "SET SKUFILE.CURR_BAL = [CURR_BAL] + [QTYTTLS] " _
             & "WHERE (((TEMPY.QTYTTLS) Is Not Null));"
    dbs.Execute (strSQL)
 
    dbs.Close
    
    Set dbs = Nothing
    strSQL = ""
    'DATA IMPORT AND ALL PROCESSING DONE.

End Sub 'END OF UPDATE SKU CURRENT BALANCE TOTALS

Actually, hexadecimal images would have been more appropriate for this page; though binary, quaternary, and octal lessons are included in the reference as well.

More by this Author


Comments 6 comments

JOHN 5 years ago

thank you very much for all this information


jeyamaran 5 years ago from India

thx 4 posting dude


newarrival4u 4 years ago

nice post ........


Java Programs profile image

Java Programs 4 years ago from India

Hi paradigmsearch,

Very informative post .... I love java language .... But was studying how other frameworks work .... Good hub ... well done .... keep the good work up .....

Thanks


Patty Kenyon profile image

Patty Kenyon 4 years ago from Ledyard, Connecticut

Awesome code!!! I love programming in VB, but lately have been programming in Java for fun!!! Thanks for sharing your code!!!


Demichris 22 months ago

Thank you very much for such complete and pro- source of code.

I was looking for that :-)

    Sign in or sign up and post using a HubPages Network account.

    0 of 8192 characters used
    Post Comment

    No HTML is allowed in comments, but URLs will be hyperlinked. Comments are not for promoting your articles or other sites.


    Click to Rate This Article
    working