Results 1 to 7 of 7
  1. #1
    anandram is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    27

    Check path in another form and create folder

    Hi all,

    I had a LOT of fields in a form that was based on a table. I had a lot of buttons that would check a DIR for it's existence and then create a folder, for example like so:

    Code:
    Dim test As String
    
    test = "Product Change"  'testing concept
    
    ChDir "c:\Company\" & Product_Name 
    
    ChDir "VARIATIONS"
    
    ChDir Internal_Reference & " " & "Variation" 
    On Error Resume Next
    
    MkDir (test)
    MsgBox "The Product Change folder for this variation has been created or already exists - Press Open Dir Button"
    End Sub


    The above is only creating the "Product Change" directory.
    The directory path would look like so based on all the above:

    C: > Company > Product Name > VARIATIONS > "Internal Ref & Variation" > Product Change


    My form is becoming slow, so i want to move fields that are related to "PRODUCT CHANGE" folder (and few others) to a new form. How would i reference the change in the above code so i can create the product change dir in the new form bearing in mind it takes fields from the 1st form?


    For arguments sake the current form can be named FORM1, and the new form for the moved fields FORM2.

    hope thats clear enough look forward to responses.

  2. #2
    jgelpi16 is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544
    You may have thought of this already...Could you use a function and reference the function?

  3. #3
    anandram is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    27
    Quote Originally Posted by jgelpi16 View Post
    You may have thought of this already...Could you use a function and reference the function?
    Hi jgelpi,

    Perhaps But i think there is just a simple reference i can use in the existing code, the code for the "create product change folder" button in form 2 would basically say "take the name of field x in form 1..." & "take the name of field y in form 1".. and make the folder named as such.

    It's just referencing/taking the string from a field name from another form to create a folder basically, but i'm not sure what vb code is.


    Hope im making sense?

  4. #4
    jgelpi16 is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544
    I think you are. Are you talking about Form_frmName.TextboxName.Value?

    Code:
    Dim strTextBoxValue as String
    
    strTextBoxValue = Form_Form1.txtTextBox.Value
    Is that what you are talking about?

  5. #5
    anandram is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    27
    Yes this is what i was talking about! Could you give me an example based on the code i wrote above? So for example:

    I would have 2 forms. Form 1 would have the fields as mentioned in the code, so Product_Name, Internal_Reference etc would all be in form 1.

    Form 2 would have the button that says "create Product change folder"..so form 2 has to reference/take whatever string is in the appropriate fields in form 1.

    It's basically what you said above butnot sure where to put the relevant code..

    Thanks for your help Sir!

  6. #6
    jgelpi16 is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544
    Ok, great! You would put all this code in your destination form. This is going to be more "pseudo-code". The idea is this...When referencing an object on another form (text box, check box, combo box, etc...) you need to tell VBA where to look. So you start out with "Form" if it is a form, "Report" if it is a report, etc...You then need to tell it your form name, so "Form_Form1". From this point on you can reference the object just like you would on the native form. Form_Form1.Product_Name.Value. Now let's look at it in code...

    Code:
    Dim strProdName as String, strInternalRef as String
    
    strProdName = Form_Form1.Product_Name.Value
    strInternalRef = Form_Form1.Internal_Reference.Value
    
    txtProdName.Value = strProdName
    txtInternalReference.Value = strInternalRef
    The txtProdName and txtInternalReference will be your text boxes on Form2. If you want the data to be brought over when the user clicks a button you should put this code in the "On Click" event. You can also set your local objects equal to the value of your "foreign" objects directly.

    Code:
    txtProductName.Value = Form_Form1.Product_Name.Value
    I just prefer to assign to variables first. Keep in mind I defined all my variables as String for this example. You may need to define them as Integer, Long, etc...If you data type(s) is/are different. I hope this helps!

  7. #7
    anandram is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    27
    Hi again, thanks for your help, sorry but i didnt get notified that you responded I would have posted back earlier otherwise. Ill check out your help and get bcak to you.

    By the way, good job on keeping the explanations simple, that is always a great help to newbies like me..keep up the good work!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Enter a folder name and open that folder
    By pkstormy in forum Code Repository
    Replies: 0
    Last Post: 09-05-2010, 04:39 PM
  2. Replies: 2
    Last Post: 07-31-2010, 11:45 PM
  3. To check or Un-Check all Boxes in a form
    By devcon in forum Forms
    Replies: 7
    Last Post: 05-01-2010, 12:03 AM
  4. create On Click to go to specific server folder
    By airhud86 in forum Programming
    Replies: 1
    Last Post: 01-05-2010, 12:45 PM
  5. Replies: 0
    Last Post: 12-16-2009, 09:28 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums