Results 1 to 8 of 8
  1. #1
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Send Object (A 2k)

    My splash form creates a folder upon startup on a location on the hard drive.
    The form itself uses an image from this folder ie linked.
    The code I use:


    Dim strFolderPath As String
    strFolderPath = "C:BICImage"
    If Len(Dir(strFolderPath)) = 0 Then
    MkDir strFolderPath
    ' Copy image from a location and insert it into the folder
    ' Now the image is there, the next line of code can proceed.
    Me.Picture = ImgLocation
    End If

    Creates the folder but I need to send the Image also and put it in the created folder.
    I've checked the help files and can't find any reference to how to do this.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Send Object (A 2k)

    The FileCopy instruction copies a file to another location. Its general syntax is

    FileCopy source, destination

    So say that the image resides in F:ImagesSplash.jpg. The following instruction will copy this file to c:BICImage.

    FileCopy "F:ImagesSplash.jpg", strFolderPath & "" & "Splash.jpg"

  3. #3
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Send Object (A 2k)

    Hans
    Perfect, Exactly what I needed.
    Thanks and have a good weekend.

  4. #4
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Send Object (A 2k)

    Hans
    On testing it doesn't work.
    I have "BICimage" folder already on my C drive so have renamed it "BICimageTEMP" for testing purposes.
    When the code executes, it doesn't create the folder or transfer the images.
    If I leave "BICimage" as it is and just remove the two bitmaps, the code works and tranfers the images. The form opens as it should with its relevant image.
    Can you see something in the code which is incorrect.
    I have also tested on another machine with the same result.

    Option Compare Database
    Option Explicit

    Private Sub Form_Close()
    DoCmd.Hourglass False
    End Sub

    Private Sub Form_Load()
    On Error Resume Next

    DoCmd.Hourglass True
    Dim strFolderPath As String

    strFolderPath = "C:BICImageUtilities"

    If Len(Dir(strFolderPath)) = 0 Then
    MkDir strFolderPath
    FileCopy "L:BICopen.bmp", strFolderPath & "" & "BICopen.bmp"
    FileCopy "L:SBimage.bmp", strFolderPath & "" & "SBimage.bmp"
    MsgBox "Files Copied"
    Me.Picture = ImgLocation
    End If
    End Sub

    Private Sub Form_Timer()
    DoCmd.Hourglass True
    Dim stDocName As String
    stDocName = "Switchboard"
    Static intCount As Integer
    If IsNull(txtCompanyCheck) Then
    DoCmd.Close acForm, Me.Name
    MsgBox "You Must Enter Your Company Information Before You Proceed"
    DoCmd.OpenForm "frmCompanyNew"
    Else
    intCount = intCount + 40
    ctlProgBar.Value = intCount
    If intCount = 4000 Then
    DoCmd.Close acForm, "Splash"
    DoCmd.OpenForm stDocName
    End If
    End If
    End Sub

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Send Object (A 2k)

    Dave,

    1. By default, Dir returns file names; if you want to use it to return a folder name, you must specify vbDirectory as second argument.
    2. You can't use MkDir to create more than one level of folders at once, you must create each level separately.
    3. What is ImgLocation?
    4. By putting On Error Resume Next at the start of the On Load code, you'll never find out where things go wrong.

    The code could look like this:

    Private Sub Form_Load()
    Dim strFolderPath As String, strMainFolder As String
    On Error GoTo ErrHandler
    DoCmd.Hourglass True

    strMainFolder = "C:BICImages"
    strFolderPath = "C:BicImagesUtilities"

    ' Check if BICImages folder exists
    If Dir(strMainFolder, vbDirectory) = "" Then
    MkDir strMainFolder
    ' Check if Utilities subfolder exists
    If Dir(strFolderPath, vbDirectory) = "" Then
    MkDir strFolderPath
    ' Copy files to subfolder
    FileCopy "L:BICopen.bmp", strFolderPath & "BICopen.bmp"
    FileCopy "L:SBimage.bmp", strFolderPath & "SBimage.bmp"
    MsgBox "Files Copied"
    End If
    End If
    'Me.Picture = ImgLocation ' HansV: what is this?
    Exit Sub

    ErrHandler:
    MsgBox Err.Description, vbExclamation
    End Sub

  6. #6
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Send Object (A 2k)

    Thanks Hans.
    The code is fine now.

    "ImgLocation" was a Global Constant in a utility module. but seeing as it only refers to two forms, "Splash" & " Switchboard", I've removed them and put them in the relevant forms instead.

    I realise the failt was with the double folder combination, but oding them separately, I hadn't encountered.

  7. #7
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Send Object (A 2k)

    Hans
    Just a thought.
    Using this method. I'm sure this would be the same principal to copy any DLL's and OCX's to the system(32) folder.
    But would they still need registering ??

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Send Object (A 2k)

    Yes, most DLL's etc. need to be registered before you can use them.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •