how to add save with VBA code (1 Viewer)

wizzina

New member
Local time
Today, 01:21
Joined
May 19, 2020
Messages
13
please i need your help am a newbie, i have a VBA codes that have browse, open and print in access but i want to add save to it that enables the file that is browsed to be saved but i cant go further please great programmers in the forum help me: the following are the codes in the form with a PDF showing image of what i have done so far:

Code:
Option Compare Database
Option Explicit

Private Sub cmdBrowse_Click()

    On Error GoTo Err_Handler
   
    Dim strFullpath As String
    Dim strFolder As String
    Dim strFile As String
    Dim intPos As Integer
   
    strFullpath = BrowseFile
   
    If strFullpath <> "" Then
        ' get folder and file names
        intPos = InStrRev(strFullpath, "\")
        strFolder = Left(strFullpath, intPos - 1)
        strFile = Mid(strFullpath, intPos + 1)
       
        ' populate text boxes on form
        Me.txtFullPath = strFullpath
        Me.txtFolder = strFolder
        Me.txtFile = strFile
    End If
   
Exit_Here:
    Exit Sub
   
Err_Handler:
    MsgBox Err.Description
    Resume Exit_Here

End Sub

Private Sub cmdOpen_Click()

    If Not IsNull(Me.txtFullPath) Then
        ShellToFile Me.txtFullPath
    End If
   
End Sub


Private Sub cmdPrintFile_Click()

    If Not IsNull(Me.txtFullPath) Then
        ShellToFile Me.txtFullPath, OP_PRINT
    End If

End Sub

Private Sub Form_Resize()

    ' revert to Windows default printer
    Set Application.Printer = Nothing

End Sub

Private Sub txtFile_Click()

    cmdOpen_Click
    Me.cmdOpen.SetFocus
   
End Sub

Private Sub txtFolder_Click()

    If Not IsNull(Me.txtFolder) Then
        ShellToFile Me.txtFolder
        Me.cmdOpen.SetFocus
    End If

End Sub

Private Sub txtFullPath_Click()

    cmdOpen_Click
   
End Sub
 

Attachments

  • Doc1.pdf
    81.7 KB · Views: 457
Last edited by a moderator:

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 08:21
Joined
May 7, 2009
Messages
19,242
create a Table with the following structure:

tblMedReport (tablename)
Full Path (short text)
Folder (short text)
File Name (short text)

bring your form in Design View.
set the Form's Recordsource: tblMedReport
click on the textbox (Full path).
on its Property Sheet->ControlSource=Full Path
click on textbox (folder)
set its ControlSource to Folder.
set the ControlSource of File Name textbox to File Name

add another button on the form (Save) to save your record.
on its Click event:

DoCmd.RunCommand acCmdSaveRecord
 

wizzina

New member
Local time
Today, 01:21
Joined
May 19, 2020
Messages
13
thanks master i appreciate but it was almost close to what am looking for, i wanted to make use of the browse, open, and print buttons as they already exist in my code, i just want the save button to follow with my existing vba codes, please master help me, am stock
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 08:21
Joined
May 7, 2009
Messages
19,242
you need a Table so you can save it?
 

Isaac

Lifelong Learner
Local time
Yesterday, 17:21
Joined
Mar 14, 2017
Messages
8,777
What do you mean Save it? They've browsed for a file that presumably exists, so it's already saved.

Do you mean you want to insert information about this file into your database - like the location and name? Or do you mean you want to copy the file to another location?
 

Micron

AWF VIP
Local time
Yesterday, 20:21
Joined
Oct 20, 2018
Messages
3,478
Maybe the 'save' refers to saving changes that the user has made to a file? I would think that whatever application has served up the file would take care of that when you close it? I guess clarification is needed as to exactly what the real goal is.
 

wizzina

New member
Local time
Today, 01:21
Joined
May 19, 2020
Messages
13
this is what i intend to achieve check the attachment pls
 

Attachments

  • browse.accdb
    500 KB · Views: 455

Isaac

Lifelong Learner
Local time
Yesterday, 17:21
Joined
Mar 14, 2017
Messages
8,777
What's the code for BrowseFile?
Seems like you would just take the variables coming out of that and assign them as values to the controls on the form. Kind of like anelgp said
 

Isaac

Lifelong Learner
Local time
Yesterday, 17:21
Joined
Mar 14, 2017
Messages
8,777
See my other reply on your semi-duplicate post about that..
 

smig

Registered User.
Local time
Today, 03:21
Joined
Nov 25, 2009
Messages
2,209
What exactly do you mean by "Save"? 🤔
The file is already there, on the computer.
Do you mean to "Save as..." giving it a new name?
 

wizzina

New member
Local time
Today, 01:21
Joined
May 19, 2020
Messages
13
What exactly do you mean by "Save"? 🤔
The file is already there, on the computer.
Do you mean to "Save as..." giving it a new name?
please sir simply give me a code for a browse button that attach any type of file
 

wizzina

New member
Local time
Today, 01:21
Joined
May 19, 2020
Messages
13
the error is caused of insufficient right to windir.
i change to copy to myDocuments.
hi Master, please i need help, am in an emergency situation, am not too good in Access put i want to achieve the following: a browse, open and import in access form for in the following file types: word, access, excel and pdf, with table where all the imported files will be stored, please help me if you can give me a step by step process to achieve this or help me to do it for me i will be greatfull and send back so i can put it on the database am working on, attached is a pdf file that shows what i want to archieve. thanks great programmer
 

Attachments

  • Doc1 (1).pdf
    79.1 KB · Views: 230

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 17:21
Joined
Oct 29, 2018
Messages
21,473
hi Master, please i need help, am in an emergency situation, am not too good in Access put i want to achieve the following: a browse, open and import in access form for in the following file types: word, access, excel and pdf, with table where all the imported files will be stored, please help me if you can give me a step by step process to achieve this or help me to do it for me i will be greatfull and send back so i can put it on the database am working on, attached is a pdf file that shows what i want to archieve. thanks great programmer
Hi. This is an old thread, and you already started one here:
 

wizzina

New member
Local time
Today, 01:21
Joined
May 19, 2020
Messages
13
Hi. This is an old thread, and you already started one here:
all what a asked for has not be given any answers, instead excuses by replying that my question is not understood
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 17:21
Joined
Oct 29, 2018
Messages
21,473
all what a asked for has not be given any answers, instead excuses by replying that my question is not understood
So, instead of attaching an explanation of what you want in another thread, why not attach it to the one you created where responders where asking for it?
 

wizzina

New member
Local time
Today, 01:21
Joined
May 19, 2020
Messages
13
So, instead of attaching an explanation of what you want in another thread, why not attach it to the one you created where responders where asking for it?
ok am sorry about it, attached is what i intend to archieve so help with a step by step proceedure or do it for me so that i can add to the database am working thanks.
 

Attachments

  • Doc1 (1).pdf
    79.1 KB · Views: 441

Users who are viewing this thread

Top Bottom