By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,608 Members | 1,940 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,608 IT Pros & Developers. It's quick & easy.

VBA Code to Wait for User Input & Form Closes

P: 2
Hi,

I am currently working on a project that i was asked to do for my boss.

What does the project consist of...

First of all I need to select some pictures from a disk/drive, they will then be copied to a default directory.

Until this point all goes perfect, Now I need to give the user a choice to create a sub folder within the default directory.

This is done by opening a new form with two text boxes...

ClientName and sFolder

The text box "ClientName" should receive from the first form the clients name and the second text box "sFolder" is where the user will give the name for the new folder.

when the new folder name has been given the user can then press a command button that should create a folder based on the "sFolder" text box...

the name should then pass to a text box on the first form where it will be defined as a string to be used as the new default location for the copy code.

NOTE:
The copy code and the create folder code both work fine.

The problem comes when I need the code to pause so the user can type in the new folder name on form2.

I have read a post made some years ago stating that using the acDialog in the open form function should resolve this.

Here is the Link http://bytes.com/topic/access/answer...il-form-closes

how ever...this is not working for me, I would much appreciate it if someone could show me where I am going wrong?

I have noticed that the ClientName does not get passed over to form2, & if i paste the name from the open client into the text box "ClientName" on form2 then enter the name for the new folder into "sFolder" the code does work.

It seems whilst in acDialog mode the text does not get passed from form1 to form2.

Here is the code...


Expand|Select|Wrap|Line Numbers
  1.  Set fd = Application.FileDialog(msoFileDialogFilePicker)
  2.  
  3.  
  4.  
  5. antw = MsgBox("Would you like to create a project directory?", 68, "Yes Or No?")
  6.     If antw = 6 Then
  7.  
  8.  
  9.     GoTo CopyToNewPath
  10.  
  11.         Else
  12.  
  13.     GoTo CopyToMainPath
  14.  
  15. CopyToNewPath:
  16.  
  17.     localid = Me.Klantnaam
  18.     stdocname = "CreateImgSubFldr"
  19.     DoCmd.OpenForm stdocname, acNormal, WindowMode:=acDialog
  20.  
  21.     Forms!CreateImgSubFldr!ClientName = localid
  22.  
  23.     ToPath = "C:\DB_Data\Data" & "\" & ClFldImageName & "\" & "Photos" & "\" & Me.fName & "\"
  24.  
  25.     With fd
  26.  
  27.     .ButtonName = "Select"
  28.     .AllowMultiSelect = True
  29.     .Filters.ADD "Images", "*.bmp;*.jpg;*.png", 1
  30.     .Filters.ADD "All Files", "*.*", 1
  31.     .Title = "..........Choose Photos to import!"
  32.     .InitialView = msoFileDialogViewDetails
  33.  
  34.         If fd.Show Then
  35.  
  36.         For i = 1 To fd.SelectedItems.Count
  37.         sFile = Filename(fd.SelectedItems(i), sPath)
  38.  
  39.         Set objFSO = CreateObject("Scripting.FileSystemObject")
  40.         Set objFileCopy = objFSO.GetFile(sFile)
  41.         objFileCopy.Copy (ToPath)
  42.  
  43.     Next
  44.  
  45. GetImages
  46.  
  47.             Else
  48.  
  49.         End If
  50.  
  51. End With
  52.  
  53. GoTo nd
May 3 '14 #1
Share this Question
Share on Google+
1 Reply


P: 2
Hi,

Mark again...

Solved, I was right before my eyes :-), just set the default value of the clientname textbox to that of the client on the open form.

Problem was in acDialog mode the way of passing the text via Forms!FormName!TxtBox = me.Whatever will not work when in acDialog mode.

Grtz
May 3 '14 #2

Post your reply

Sign in to post your reply or Sign up for a free account.