Results 1 to 8 of 8
  1. #1
    jker is offline Advanced Beginner
    Windows 10 Access 2007
    Join Date
    Aug 2023
    Posts
    36

    Help with storing directory name into a table

    I have a table named CUSTOMER and it has a text column to store the customer directory path,

    I put in code to create the directory in the on the users C: drive, and that works correctly. The problem i have is that i get a compile error when i try to store the directory name into the table column (CUST_DIR)

    '*************************************************
    '** make a DOS directory for new customer
    '*************************************************



    Dim strpath As String

    strpath = "C:\globalbeauty\images\cust-" & CUST_ID

    If Dir(strpath, vbDirectory) > vbNullString Then 'test for directory existing
    Exit Sub
    End If

    MkDir strpath

    Me.CUST_DIR = strpath

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Is this code behind a form bound to that table? What event is code in? Which line triggers the compile error?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    No need to store the CustID, you can append that any time you need the path.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  4. #4
    jker is offline Advanced Beginner
    Windows 10 Access 2007
    Join Date
    Aug 2023
    Posts
    36
    here are the screen shots of what is happening:
    Click image for larger version. 

Name:	code.JPG 
Views:	9 
Size:	64.1 KB 
ID:	50926Click image for larger version. 

Name:	deisgn.JPG 
Views:	10 
Size:	128.3 KB 
ID:	50927Click image for larger version. 

Name:	table.JPG 
Views:	9 
Size:	55.0 KB 
ID:	50928

  5. #5
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    My guess is that CUST_DIR may be the name of the field that the control is bound to but that is not the name of the control. The message is fairly straight forward - code has no idea what CUST_DIR is as a data member.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  6. #6
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    My thoughts exactly.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  7. #7
    jker is offline Advanced Beginner
    Windows 10 Access 2007
    Join Date
    Aug 2023
    Posts
    36
    thank you|||| that was the problem incorrect control name

  8. #8
    Join Date
    Apr 2017
    Posts
    1,680
    An advice - don't never use same name for control and for name of field it is linked to. I myself prefer name controls with prefixes indicating control type. E.g.
    Table field name TableField. The control linked to this field: txtTableField when text box, cbbTableField when combo box, etc.

    The similar convention I use for naming subforms. E.g. I have forms fMyForm1 and fMyform2. When I insert fMyForm2 as subform into fMyForm1, then I name the subform control in fMyForm1 as sfMyForm2 (NB! The default name Access uses will be same as form inserted as subform has!). The form fMyForm2 will be a source of subform sfMyForm2.

    With this, both you yourself, and your Access app, always know exactly, what was referred to in script!

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

Similar Threads

  1. Storing a decimal in a table
    By DC CS in forum Access
    Replies: 6
    Last Post: 06-13-2023, 07:03 AM
  2. Storing an object in a table
    By Paul H in forum Programming
    Replies: 2
    Last Post: 08-26-2013, 07:28 AM
  3. Replies: 6
    Last Post: 10-26-2012, 12:53 PM
  4. Storing code in a table
    By jgelpi16 in forum Programming
    Replies: 4
    Last Post: 07-27-2011, 07:22 PM
  5. Replies: 6
    Last Post: 06-15-2011, 04:38 PM

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