Save as dialog

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • wheeto
    New Member
    • Feb 2007
    • 5

    #1

    Save as dialog

    Hi

    I'm new to vb 2005 and am having problems with save as dialog code, when i go to save a file it returns "file not found" but when it looks at a file on the pc then it will save,
    can someone help & tell me whats missing?? i have listed the code below

    Code:
    Dim iResult As DialogResult
            iResult = SaveFileDialog1.ShowDialog()
            SaveFileDialog1.Title = "Specify a Name for the File"
            SaveFileDialog1.Filter = "Text Format (*.txt) | *.txt"
            SaveFileDialog1.AddExtension = True
            SaveFileDialog1.OverwritePrompt = True
            SaveFileDialog1.InitialDirectory = "C:\"
            SaveFileDialog1.FileName = ""
            If iResult <> Windows.Forms.DialogResult.Cancel And SaveFileDialog1.FileName.Length <> 0 Then
                F3mainreport.SaveFile(SaveFileDialog1.FileName)
             End If
    Many Thanks
    Last edited by willakawill; Feb 7 '07, 02:21 PM. Reason: please use code tags when posting code
  • willakawill
    Top Contributor
    • Oct 2006
    • 1646

    #2
    A quick look at your code and I think you may want to open the save dialog after you have set the properties

    Code:
    Dim iResult As DialogResult
            
            SaveFileDialog1.Title = "Specify a Name for the File"
            SaveFileDialog1.Filter = "Text Format (*.txt) | *.txt"
            SaveFileDialog1.AddExtension = True
            SaveFileDialog1.OverwritePrompt = True
            SaveFileDialog1.InitialDirectory = "C:\"
            SaveFileDialog1.FileName = ""
            iResult = SaveFileDialog1.ShowDialog()
            If iResult <> Windows.Forms.DialogResult.Cancel And SaveFileDialog1.FileName.Length <> 0 Then
                F3mainreport.SaveFile(SaveFileDialog1.FileName)
             End If

    Comment

    • wheeto
      New Member
      • Feb 2007
      • 5

      #3
      Thanks for the help,
      I have changed the code and i still get up the message box

      "File C:\testfile does not exist"
      "Verify that the correct file name was given"

      If i select a file the exists, it will over write the file, not create a new one.

      I have tried changing the code around, but with no luck,
      I have searched the internet for answers, but have drawn a blank.
      I can normaly find an answer that can help with other problems, but not this one.

      Comment

      • willakawill
        Top Contributor
        • Oct 2006
        • 1646

        #4
        At what point in your code does this error come up?
        Is it when you call the save for your report?

        Comment

        • wheeto
          New Member
          • Feb 2007
          • 5

          #5
          Originally posted by willakawill
          At what point in your code does this error come up?
          Is it when you call the save for your report?

          The problem is when i build & test the program, i can create a report in my program then try to save the text box with the save as commard, the error then appears.It is as if i have left out a piece of code that tells the system to create a new file if its not already present.

          Comment

          • willakawill
            Top Contributor
            • Oct 2006
            • 1646

            #6
            I mean when you are debugging. Which line creates the error?

            Comment

            • wheeto
              New Member
              • Feb 2007
              • 5

              #7
              Originally posted by willakawill
              I mean when you are debugging. Which line creates the error?

              Sorry my mistake, the line code doesn't create an error, The program shows the error when running.
              The error box shows when you type a file name that doesn't exist on c drive, but if the file already exists on the c drive it will save as normal.

              I have also published the program and installed it to see if the error message still shows when installed and running, and it does still show.
              I must have missed a line of code somewhere that tells the system to create a new file if one doesn't exist.
              Hope this helps, as i have run out of ideas.

              Many thanks for your help

              Comment

              Working...