Results 1 to 7 of 7
  1. #1
    Synergy.ron@gmail.com is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Oct 2020
    Location
    washington
    Posts
    35

    unbound fielf on bound form? Problem?

    i have a membership app, It has a bound Membership form with 2 unbound fields, txt_Serial & txt_unlockCode. In trying to debug the main procedure I noticed I can not write a "string" to the unbound field...?

    using debug.print shows that things are working but the txt fields do no get values. What don't I see? thanks


    Click image for larger version. 

Name:	unbound fields.png 
Views:	20 
Size:	6.4 KB 
ID:	44929


    Click image for larger version. 

Name:	verify serial.png 
Views:	20 
Size:	6.4 KB 
ID:	44928
    Attached Files Attached Files

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    50,017
    I am unable to open tblAddresses and forms using that table because I use Access2010. Your db is not backwards compatible.

    I removed tblAddresses from frmMembers so I can open that form.

    What is purpose of these two unbound controls? VBA setting their values will display same info on every row of form.

    Since procedure is in a general module, cannot reference those controls without form prefix. Following lines fail:
    [txt_serial] = str3
    Debug.Print [txt_unlockCode]
    Forms!Form![txt_unlockCode]
    Forms!Form!frmMembers![txt_unlockCode]

    Consider:
    Code:
    Public Sub verifyserial()
    Randomize
    Forms!frmMembers.[txt_serial] = Int(Rnd(7) * 1000000)
    Forms!frmMembers.[txt_unlockCode] = "DEMOH"
    End Sub
    Suggest putting this procedure behind form so:
    Code:
    Private Sub verifyserial()
    Randomize
    Me.[txt_serial] = Int(Rnd(7) * 1000000)
    Me.[txt_unlockCode] = "DEMOH" 
    End Sub
    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
    Synergy.ron@gmail.com is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Oct 2020
    Location
    washington
    Posts
    35
    Thanks for the speedy and insightful reply. the purpose of txt_serial is to hold a random 6 digit number and serve as the basis for the txt_unlockcode--- which will tell me if a user is authorized. In my code i was just trying to get txt_Unlockcode to accept 'any' text(as proof of concept. using your method WORKS. thanks again

  4. #4
    ssanfu is offline Master of Nothing
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,273
    Other issues

    Reserved words:
    tblPhones - Type, Memo, Primary
    USzipcodes - Type
    tblAddresses - Type, Primary

    Check spelling. In table LodgeInfo - field name => ": odgeNum" .......Shouldn't it be "LodgeNum"? (I had to add a space after the colon, otherwise the editor displays a smiley face => )

    There are spaces in field names - should NOT use spaces in object names
    There are 12 Look Up FIELDS
    There is 1 calculated field



    Good luck with your project...
    HTH
    -----
    Steve
    --------------------------------
    "Veni, Vidi, Velcro"
    (I came; I saw; I stuck around.)

  5. #5
    Synergy.ron@gmail.com is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Oct 2020
    Location
    washington
    Posts
    35
    yes, i need to cleanup my field names. but, todays puzzle is : i have a general procedue with a sub routine that is called from the form's ON LOAD event. Click image for larger version. 

Name:	prop verify serial.png 
Views:	9 
Size:	8.0 KB 
ID:	44935the sub works from debug but fail when i open the form. thanks.....

    Click image for larger version. 

Name:	msft can not find.png 
Views:	9 
Size:	7.5 KB 
ID:	44936

  6. #6
    Synergy.ron@gmail.com is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Oct 2020
    Location
    washington
    Posts
    35
    corrected the 'verifyserial' setting.....oops. same result?????? when frmmembers is opened??

  7. #7
    ssanfu is offline Master of Nothing
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,273
    What is the code you have now?

    This has invalid syntax
    Code:
    Forms!Form![txt_unlockCode]
    (has the word FORM and missing the form name)


    The reference to the control "txt_unlockCode" on the form "frmMembers" from a standard module should be
    Code:
    Forms!frmMembers.txt_unlockCode
    If you want to leave "Sub verifyserial()" in a standard module, the code would be
    Code:
    Option Compare Database
    Option Explicit
    
    Public Sub verifyserial()
        Dim str3   As String
        Dim i      As Integer
        Dim txt_serial As String
        Dim PASS(6) As String
    
        Randomize
        str3 = Int(Rnd(7) * 1000000)
        
        Forms!frmMembers.txt_serial = str3
        Debug.Print str3
        Debug.Print Forms!frmMembers.txt_unlockCode
        Forms!frmMembers.txt_unlockCode = "DEMOH"    
        MsgBox Forms!frmMembers.txt_unlockCode
        
        MsgBox str3
        Debug.Print Forms!frmMembers.txt_unlockCode
        
        'CREATE UNLOCK CODE   in process
        
    End Sub

    If you move the routine to the form module, the the code would be
    Code:
    Option Compare Database
    Option Explicit
    
    Private Sub Form_Load()
        verifyserial
    End Sub
    
    Public Sub verifyserial()
        Dim str3   As String
        Dim i      As Integer
        Dim txt_serial As String
        Dim PASS(6) As String
    
        Randomize
        str3 = Int(Rnd(7) * 1000000)
        
        Me.txt_serial = str3
        Debug.Print str3
        Debug.Print Me.txt_unlockCode
        Me.txt_unlockCode = "DEMOH"
        MsgBox Me.txt_unlockCode
        
        MsgBox str3
        Debug.Print Me.txt_unlockCode
        
        'CREATE UNLOCK CODE   in process
        
    End Sub
    Pick either a standard module OR form module - code cannot be in both places at the same time with the same name.


    Note: this is just restating what June7 said...........
    Attached Files Attached Files
    HTH
    -----
    Steve
    --------------------------------
    "Veni, Vidi, Velcro"
    (I came; I saw; I stuck around.)

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

Similar Threads

  1. How to filter bound subform from unbound main form?
    By ittechguy in forum Programming
    Replies: 3
    Last Post: 10-25-2015, 09:12 PM
  2. Bound vs unbound checkboxes on a form
    By sanderson in forum Forms
    Replies: 21
    Last Post: 08-26-2015, 06:45 AM
  3. Replies: 11
    Last Post: 10-23-2014, 11:12 PM
  4. unbound vs bound in my form
    By broecher in forum Forms
    Replies: 5
    Last Post: 11-17-2012, 07:53 PM
  5. Unbound textbox in bound form
    By Evilferret in forum Forms
    Replies: 5
    Last Post: 08-15-2012, 01:26 PM

Tags for this Thread

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 - Senior Forums