Results 1 to 15 of 15
  1. #1
    Jacqueline is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2012
    Posts
    12

    Clearing multiracial text box when form opens

    Good morning all,
    I have a form with a combo where users input an ID to find the student record they need. I was able to get it to set to null on open of the form, otherwise the first ID in the list shows, using the code below in the VB editor. It works great for the combo select but when I try to add the code for the corresponding text box that show the user the name an ID of the student they have selected it get all kinds of errors. Can there only be one programmed action for the Current()? I am really, really, rusty in the use of VBA... so any help would be greatly appreciated.
    Thank you,
    Jacqueline

    Private Sub Form_Current()


    On Error GoTo ErrorHandler


    Me![Combo23] = Null
    Exit Sub
    ErrorHandler:
    MsgBox "Error No: " & Err.Number & ": Description: " & Err.Description
    End Sub

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,625
    Current event can do many actions. Only showing one.

    Why do you need to use code to show name and ID of student? Is this a bound form? Is the combobox bound?
    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
    Jacqueline is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jan 2012
    Posts
    12
    I want the student ID and Name box to be blank or Null when the form opens for the user. Right now the first student in the table the form is built upon shows in the student ID text box and student name text box. My users are very basic and it will confuse them to see a name and ID before they have used the combo to select a student. I tried including multiple objects in the code for On Current but I must not be holding my mouth right or something...
    Jacqueline

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,625
    Didn't really answer all my questions.

    If the form is bound and the controls are bound to fields, cannot set them to Null because that will change data in record.

    One option is to open form to new record row - code in the form Open event
    DoCmd.GoToRecord , , acNewRec
    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.

  5. #5
    Jacqueline is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jan 2012
    Posts
    12
    This will not work because the data table the basic information is being pulled from does not allow the user to enter or change data. The data populates from tables that are linked to state student management system. They need to see the information but not change it.

  6. #6
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,848
    What exactly are you trying to accomplish - plain English - no Access no forms, no combo?
    Once we know What, we may be able to offer some options for How.

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,625
    How does user open the form - a button on a 'main menu' form?

    Have user input a criteria first, then apply that when opening form.

    DoCmd.OpenForm "formname", , , "StudentID='" & Me.cbxStudent & "'"

    or try:

    Private Sub Form_Open(Cancel As Integer)
    Me.Filter = "StudentID='X'"
    Me.FilterOn = True
    End Sub

    Is StudentID a number or text type?
    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.

  8. #8
    Jacqueline is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jan 2012
    Posts
    12
    The user will input an ID into a combo box, this brings up the associated student record, from the linked tables pulled for the student management system. I was able to get the combo to be clear when the user opens the form by using the code in the first post. However the text boxes for the student name and ID are populated with the first record in the table where the combo looks.

    Once the user finds the correct student, by entering the ID into the combo box, they can input into the associated sub form the progress data they are tracking. The data goes into a sub form that feeds a table outside of the tables from the student management system, we cannot write to these tables, where we pull the demographic data for the students.

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,625
    Did you try either of the options I suggested in previous post?
    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.

  10. #10
    Jacqueline is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jan 2012
    Posts
    12
    Yes, I tried the macro, but it did not work, I think because the combo looks up students from a table that cannot be modified, so you can not set a new record. The other one confused me, so did not try it. I am trying to get back into VBA but still a real novice.

  11. #11
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,625
    My suggestions in post 7 have nothing to do with new record.
    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.

  12. #12
    Jacqueline is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jan 2012
    Posts
    12
    I'm lost then, sorry ... I went into the macro builder using the goto command ... can you give me the exact steps you were indicating. Remember I'm a real novice when it comes to VBA sorry

  13. #13
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,625
    I don't use macros, only VBA which is what I posted. What exactly do you not understand about the guidance in post 7?
    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.

  14. #14
    Jacqueline is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jan 2012
    Posts
    12
    I had a little time to look at this. I went into code for the form, changed to Open, and copied your code line but it gives me a run time error... here is what I have can you tell me what I did wrong?
    Private Sub Form_Open(Cancel As Integer)
    DoCmd.GoToRecord , , acNewRec
    End Sub

  15. #15
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,625
    You said you cannot go to new record row because users are not allowed to add records. If this restriction is on the table side, then I guess that would cause error.

    Did you try alternate suggestions in post 7?
    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.

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

Similar Threads

  1. Clearing Sub Form
    By eagle670 in forum Forms
    Replies: 19
    Last Post: 06-23-2014, 02:31 PM
  2. Replies: 7
    Last Post: 07-07-2013, 11:11 AM
  3. Clearing a Form
    By dabatman in forum Forms
    Replies: 4
    Last Post: 01-20-2012, 11:51 AM
  4. Error when clearing form
    By turbo910 in forum Forms
    Replies: 11
    Last Post: 11-26-2009, 11:03 AM
  5. clearing a form
    By macsterling in forum Forms
    Replies: 0
    Last Post: 07-31-2008, 10:38 AM

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