Top DevX Stories
Creating Custom Export Filters for StarOffice with XSLT
WPF Wonders: Using DataTemplates
Crystal Reports Family Offers Options for Developers
Avaya Aura Session Manager video
Avaya Aura Overview video
Search the forums:

Go Back   DevX.com Forums > DevX Developer Forums > VB Classic

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old 10-17-2009, 01:14 PM
gweller gweller is offline
Registered User
 
Join Date: Oct 2009
Posts: 5
Database Upload Error Message

Hello,

I am very new to VB and am using VB to upload data from multiple Excel files to a single database. The Excel files are generated from a form questionnaire that will be filled out by multiple organizations and emailed back to me. Each form has certain fields which require an answer and must not be left blank.

So far I am able to upload multiple excel files from a single source directory.

I am now trying to create error messages to alert the user to missing information that has not been filled out on the forms that are being sent in.

Any Suggestions?

Any help is greatly appreciated.

Thanks!

Greg
Reply With Quote
  #2  
Old 10-18-2009, 09:07 AM
Hack's Avatar
Hack Hack is offline
Super Moderator
 
Join Date: Apr 2007
Location: Sterling Heights, Michigan
Posts: 7,719
Welcome to DevX

Are the error messages supposed to be generated before, or after, they get into the database?

If it is before, then you could modify your upload code to check the contents of specific cells prior to actually doing the import.

If after, then you could pop up a VB screen which asks for the information, and then updates the database directly (without the need for excel at all)
__________________
I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
Please use [Code]your code goes in here[/Code] tags when posting code.
Before posting your question, did you look here?
Got a question on Linux? Visit our Linux sister site.
Modifications Required For VB6 Apps To Work On Vista

Microsoft MVP 2005/2006/2007/2008/2009
Reply With Quote
  #3  
Old 10-18-2009, 11:45 AM
gweller gweller is offline
Registered User
 
Join Date: Oct 2009
Posts: 5
Error Message Generated Before Upload

Thanks for replying!

I would like to modify my upload code to check for missing information and alert and alert the user prior to it being uploaded into the database.

The purpose is for the user to be flagged and the upload prevented so that the user can send the form back to the sender to complete.

If you could provide some detail as to how to modify the code that would be great.

Thanks again,

Greg
Reply With Quote
  #4  
Old 10-19-2009, 09:04 AM
Hack's Avatar
Hack Hack is offline
Super Moderator
 
Join Date: Apr 2007
Location: Sterling Heights, Michigan
Posts: 7,719
What code do you have for your uploading?

It shouldn't be difficult to modify that to check specific cells on the spreadsheet.

These cells that must be filled out are ALWAYS in the same location on the spreadsheet, right? If the answer to this is No, then give a range name to the cell location so your code can find it no matter where it winds up.
__________________
I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
Please use [Code]your code goes in here[/Code] tags when posting code.
Before posting your question, did you look here?
Got a question on Linux? Visit our Linux sister site.
Modifications Required For VB6 Apps To Work On Vista

Microsoft MVP 2005/2006/2007/2008/2009
Reply With Quote
  #5  
Old 10-21-2009, 06:34 PM
gweller gweller is offline
Registered User
 
Join Date: Oct 2009
Posts: 5
Error Message Generated Before Upload

Yes, the fields that must be filled out will always be located in the same place.

Here is the code I am using for the upload. The code is used to upload three separate surveys that will be coming in from multiple businesses.
Code:
Private Sub LoadAdultCare_Click()
On Error GoTo Err_LoadAdultCare_Click
Dim dbsTemp As Database

Dim oFs As New FileSystemObject
Dim oFolder As Folder
Dim oFile As File

Dim Path As String
Dim NewPath As String

Path = "C:\OHEP\AdultCareBeforeLoad\"
NewPath = "C:\OHEP\AdultCareAfterLoad\"
ChDir (Path)
Set dbsTemp = CurrentDb
If oFs.FolderExists(Path) Then
    Set oFolder = oFs.GetFolder(Path)
 
    For Each oFile In oFolder.Files
           
        If oFs.GetExtensionName(oFile) = "xls" Then
            DoCmd.TransferSpreadsheet TransferType:=acImport, SpreadsheetType:=5, _
            TableName:="AdultCare", FileName:=oFile.Name, HasFieldNames:=False, _
            Range:="Data!A2:N127"
           
            oFs.MoveFile oFile.Name, NewPath + oFile.Name
           
        End If
       
    Next
   
End If
      
Exit_LoadAdultCare_Click:
    Exit Sub
Err_LoadAdultCare_Click:
    MsgBox Err.Description
    Resume Exit_LoadAdultCare_Click
End Sub

Private Sub LoadHospital_Click()
On Error GoTo Err_LoadHospital_Click
Dim dbsTemp As Database

Dim oFs As New FileSystemObject
Dim oFolder As Folder
Dim oFile As File

Dim Path As String
Dim NewPath As String

Path = "C:\OHEP\HospitalBeforeLoad\"
NewPath = "C:\OHEP\HospitalAfterLoad\"
ChDir (Path)
Set dbsTemp = CurrentDb
If oFs.FolderExists(Path) Then
    Set oFolder = oFs.GetFolder(Path)
 
    For Each oFile In oFolder.Files
           
        If oFs.GetExtensionName(oFile) = "xls" Then
            DoCmd.TransferSpreadsheet TransferType:=acImport, SpreadsheetType:=5, _
            TableName:="Hospital", FileName:=oFile.Name, HasFieldNames:=False, _
            Range:="Data!A2:N211"
           
            oFs.MoveFile oFile.Name, NewPath + oFile.Name
           
        End If
       
    Next
   
End If
      
Exit_LoadHospital_Click:
    Exit Sub
Err_LoadHospital_Click:
    MsgBox Err.Description
    Resume Exit_LoadHospital_Click
   
End Sub

Private Sub LoadNursingHome_Click()
On Error GoTo Err_LoadNursingHome_Click
Dim dbsTemp As Database

Dim oFs As New FileSystemObject
Dim oFolder As Folder
Dim oFile As File

Dim Path As String
Dim NewPath As String

Path = "C:\OHEP\NursingHomeBeforeLoad\"
NewPath = "C:\OHEP\NursingHomeAfterLoad\"
ChDir (Path)
Set dbsTemp = CurrentDb
If oFs.FolderExists(Path) Then
    Set oFolder = oFs.GetFolder(Path)
 
    For Each oFile In oFolder.Files
           
        If oFs.GetExtensionName(oFile) = "xls" Then
            DoCmd.TransferSpreadsheet TransferType:=acImport, SpreadsheetType:=5, _
            TableName:="NursingHome", FileName:=oFile.Name, HasFieldNames:=False, _
            Range:="Data!A2:N173"
           
            oFs.MoveFile oFile.Name, NewPath + oFile.Name
           
        End If
       
    Next
   
End If
      
Exit_LoadNursingHome_Click:
    Exit Sub
Err_LoadNursingHome_Click:
    MsgBox Err.Description
    Resume Exit_LoadNursingHome_Click
   
End Sub

Last edited by Hack; 10-30-2009 at 01:31 PM. Reason: Added Code Tags
Reply With Quote
  #6  
Old 10-27-2009, 05:21 PM
gweller gweller is offline
Registered User
 
Join Date: Oct 2009
Posts: 5
Error Message Generated Before Upload

I have been able to generate error messages for missing information and am now trying to figure out how to flag surveys that have already been uploaded.

If a survey has already been uploaded I would like to flag the user to be able to either continue and overwrite or abort upload.

Any suggestions?

Thanks!
Reply With Quote
  #7  
Old 10-29-2009, 11:28 AM
Hack's Avatar
Hack Hack is offline
Super Moderator
 
Join Date: Apr 2007
Location: Sterling Heights, Michigan
Posts: 7,719
What determines if the survey has been uploaded?

Will there be an entry in db table, or a specific file name in a certain folder?
__________________
I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
Please use [Code]your code goes in here[/Code] tags when posting code.
Before posting your question, did you look here?
Got a question on Linux? Visit our Linux sister site.
Modifications Required For VB6 Apps To Work On Vista

Microsoft MVP 2005/2006/2007/2008/2009
Reply With Quote
  #8  
Old 10-29-2009, 11:36 AM
gweller gweller is offline
Registered User
 
Join Date: Oct 2009
Posts: 5
Error Message Generated Before Upload

There will be a specific file name in a certain folder. I am uploading files from a "pre-uploaded folder" to a "post-upload folder" and would like a message to alert the user if he/she is trying to upload a file that already exists in the "post-uploaded" folder and allow them to either abort upload or overwrite the existing file.
Reply With Quote
  #9  
Old 10-30-2009, 01:33 PM
Hack's Avatar
Hack Hack is offline
Super Moderator
 
Join Date: Apr 2007
Location: Sterling Heights, Michigan
Posts: 7,719
Try something like this
Code:
If Dir$("C:\OHEP\AdultCareBeforeLoad\gweller.txt") <> vbNullString Then
   MsgBox "file exists"
Else
   MsgBox "file doesn't exist"
End If
__________________
I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
Please use [Code]your code goes in here[/Code] tags when posting code.
Before posting your question, did you look here?
Got a question on Linux? Visit our Linux sister site.
Modifications Required For VB6 Apps To Work On Vista

Microsoft MVP 2005/2006/2007/2008/2009
Reply With Quote
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
upload data to mysql database randjana VB Classic 1 05-05-2006 11:07 AM
Urgent: Upload image to database galgal5814 ASP.NET 1 04-05-2006 02:47 PM
File Upload to a database tam Database 2 08-10-2002 03:53 AM
Really Cool 3 tier Java database solution Russ Database 0 06-04-2002 01:57 AM
Database Security General Discussion Michael Tzoanos Database 0 04-12-2002 12:19 PM


All times are GMT -4. The time now is 01:19 AM.


Sponsored Links



Acceptable Use Policy

internet.comMediabistrojusttechjobs.comGraphics.com

WebMediaBrands Corporate Info


Advertise | Newsletters | Feedback | Submit News

Legal Notices | Licensing | Permissions | Privacy Policy


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.