Upate fields and Check fields

C

caj40

Help! I have been working on this for a LONG time (mostly piecing it together
from info on this and other sites) and ALmost have this doing what I need it
to do. (I'm using 2000, continuous form). Another button brings all the files
in the staging dir into the frmAddFile.
Problems are:
1. Can I add VBA to check and make sure that DType and Numbly have values
entered in them for each file? And if not gives a message and exits
SaveDB_Click?
2. How do I get the fields [PathFileName] and [DocFileName] to update with
the new path and filename?

Private Sub SaveDB_Click()

On Error GoTo Err_SaveDB_Click

Dim dbCurr As DAO.Database
Dim rsCurr As DAO.Recordset
Dim strFolder As String
Dim strNewFolder As String
Dim strNewFile As String
Dim strFileName As String
Dim strOldFile As String
Dim strSQL As String

strFolder = "C:\Vantage\STAGING\"
strNewFolder = "C:\Vantage\SCANS\"

strSQL = "SELECT DType, Numbly, DocFileName FROM STAGE"
Set dbCurr = CurrentDb()
Set rsCurr = dbCurr.OpenRecordset(strSQL)
If rsCurr.RecordCount = 0 Then
MsgBox "No Record In the Table"
rsCurr.Close
Set rsCurr = Nothing
Set dbCurr = Nothing
Else
With rsCurr
.MoveLast
.MoveFirst

Do While rsCurr.EOF = False

strOldFile = strFolder & rsCurr!DocFileName
strNewFile = strNewFolder & rsCurr!DType & "-" & rsCurr!Numbly & ".pdf"
strFileName = rsCurr!DType & "-" & rsCurr!Numbly & ".pdf"

Me!PathFileName.Value = strNewFile
Me!DocFileName.Value = strFileName
If Len(Dir(strOldFile)) > 0 Then

If Len(Dir(strNewFile)) > 0 Then
If MsgBox(strNewFile & " already exists." & vbCrLf & _
"Overwrite it?", vbYesNo + vbQuestion) = vbYes Then
Kill strNewFile
cancel = True
End If
Else
Name strOldFile As strNewFile


End If
End If

rsCurr.MoveNext

Loop

End With
End If

rsCurr.Close

Set rsCurr = Nothing
Set dbCurr = Nothing

yada, yada ...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top