Results 1 to 10 of 10
  1. #1
    johnlight is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2013
    Posts
    5

    #Name? Error in Unbound Combo Box

    All,



    Here is the layout of the project:
    Form that pulls data from a Sharepoint List into a linked table via the external data option.
    This list contains about 40 fields per record, so I created three maketable queries for the three tables that I need to populate some combo boxes because I don't need all the fields, just needed 4.

    All three tables have 4 columns [ID(autonum), Name(Text), Active Employee?(Boolean check), Qualifications(memo that holds check box data)] after the maketable is executed.
    Table names: VTS_WS, VTS_AWS, VTS_Operators

    I pass a SELECT statement in the Row Source to populate each combo box: SELECT VTS_WS.Name FROM VTS_WS;
    I left the Control Source box empty, thus unbounding the Combo box.

    Click image for larger version. 

Name:	screenshot.jpg 
Views:	12 
Size:	36.3 KB 
ID:	14142

    The issue is when I open the form, the fields are empty. I can select an option from the combo box without a problem, but after I save the record, the combo boxes turn into: #Name?

    I can still go back and manually select an option from the combo box, but would like to have the previous value persist in the field.

    Any thoughts?

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    I am not familiar with SharePoint. At a glance it seems your combobox is loosing its Rowsource due to the activity of the user, ie selecting an option within the combo and or saving the record.

    You will need to carry over the rowsource in a string value somehow. If you want to have the value of the User's selection carry over after being saved?... you will need to store this in a variable also. From the sound of it, these variables will need to be available globaly.

    If the Rowsurce is not available when the form opens, you will need to duplicate the action that assigns the resource. PLace this action, along with your variables into the forms load or current event...

  3. #3
    johnlight is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2013
    Posts
    5
    How do you set the a combo box source with a query in the Form_Load?

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    Control source is to relate to a field/control within the recordset. I usually do this via VBA so I will need to refresh my memory before offering more help specific to this property.

    It is my impression that your RowSource is not assigned to the combo during form load. But the #name? thing does seem to be related to placing something inside the Control Source.

    Are you updating the control source while the user is interfacing with the form? Your screenshot shows it empty so I was kinda going on assumption here.

  5. #5
    johnlight is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2013
    Posts
    5
    I am not sure how to load combo boxes in VBA. I entered the SELECT statement in in the Row Source via Property Sheet for each Combo Box.

    And I am leaving the Control Source empty to unbind the element. The only thing I am trying to do that might be related is the attemping to set the default value of the box to the current value prior to saving the record.

    Here is my VBA for clicking the save button:
    Private Sub cmd_save_Click()

    ' CHECKS TO SEE IF LOG FIELD IS EMPTY & EXITS AFTER MSGBOX
    If IsNull(Me!running_chrono.Value) Then
    MsgBox "Please enter a Log entry prior to saving.."
    Exit Sub
    End If

    ' CHECKS IS WATCH SUPERVISOR FIELD IS EMPTY
    If IsNull(Me!watch_supervisor.Value) Then
    MsgBox "Please enter name of Watch Supervisor prior to saving.."
    Exit Sub
    End If

    ' CHECKS IS WATCH ASSIST FIELD IS EMPTY
    If IsNull(Me!watch_assist.Value) Then
    MsgBox "Please enter name of Assistant Supervisor prior to saving.."
    Exit Sub
    End If

    ' CHECKS IS WATCH ROLE FIELD IS EMPTY
    If IsNull(Me!watch_role.Value) Then
    MsgBox "Please enter Watch Role prior to saving.."
    Exit Sub
    End If

    ' CHECKS IS WATCH OPERATOR FIELD IS EMPTY
    If IsNull(Me!watch_operator.Value) Then
    MsgBox "Please enter Operator name prior to saving.."
    Exit Sub
    End If

    ' SETTING TIME FIELD
    Me.CurrentTime = Now()

    ' RESET FIELDS TO PREVIOUS VALUES (IN PROGRESS)
    Me!watch_supervisor.DefaultValue = watch_supervisor.Value
    Me!watch_assist.DefaultValue = watch_assist.Value
    Me!watch_role.DefaultValue = watch_role.Value
    Me!watch_operator.DefaultValue = watch_operator.Value

    ' SAVE RECORD / NEXT RECORD / REFRESH FORM
    DoCmd.RunCommand acCmdSaveRecord
    DoCmd.GoToRecord , , acNewRec
    DoCmd.RunCommand acCmdRefresh

    ' RESETS POSITION OF SCROLLING LISTBOX
    running_chrono_listbox.SetFocus
    Me.running_chrono_listbox.Selected(0) = True

    The last portion is used because I have a running listbox showing each of the records as they are saved and I need to keep it on the top entry and not the manually selected one.

  6. #6
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    Nothing is really jumping out at me. It seems that somehow, your combobox is recieving instruction to change its Control Source property.

    You can try this in your code, where cmbTest is the name of your combobox and 1 represents a row/record within your combobox's RowSource. The value 1, or whatever value you choose, will be present within the recordset. It will be present in that specific column. The colomn your combobx is "Bound" to in the combobox's properties.

    Me.cmbTest.ControlSource = ""
    Me.cmbTest.Column.Value = 1


    This is not a solution. You mentioned your combobox is not bound. Therefore, ControlSource = "" will insure it remains unbound. Afterwards, you can hunt down what is causing your combo to become bound??

  7. #7
    johnlight is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2013
    Posts
    5
    I pulled out the default assignments, figuring that since they are messing with the combo boxes, they might be causing it. The error stopped coming up, but now I need to find a way to get the value in the box to persist after the new record is brought up (ie get value in newly saved record to stay as the selected value)

  8. #8
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    I think that is key. How you pass the value. As mentioned before, I pass values using VBA. grab the value FROM the combo and THEN pass the value to the Form's recordset or directly to a table. It seems you are somehow assigning something BACK to the combobox.

    Dim strValue as string

    strValue = Me.cmbTest.Collumn (1)

    Take the value FROM the combo and store it in a variable. Here I am grabbing the literal string from the SECOND column in the combobox. You will need a Public variable in order to pass it to another function/procedure

  9. #9
    johnlight is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2013
    Posts
    5
    I think you left me enough bread crumbs.. Here is what I came up with:

    *** SET GLOBAL VARIABLES FOR COMBOBOX PERSISTANCE - Step 1 '
    Dim WSValue, AWSVAlue, OPValue, RoleValue As String

    ' *** Saving Values to Variables - Step 2 '
    WSValue = Me!watch_supervisor.Value
    AWSVAlue = Me!watch_assist.Value
    OPValue = Me!watch_operator.Value
    RoleValue = Me!watch_role.Value

    ' SAVE RECORD / NEXT RECORD / REFRESH FORM
    DoCmd.RunCommand acCmdSaveRecord
    DoCmd.GoToRecord , , acNewRec
    DoCmd.RunCommand acCmdRefresh

    ' *** Assigning Saved Values back to Combo Boxes - Step 3 '
    Me!watch_supervisor.Value = WSValue
    Me!watch_assist.Value = AWSVAlue
    Me!watch_operator.Value = OPValue
    Me!watch_role.Value = RoleValue

    Thanks for the help, Expert. Since I will be using this function quite a bit, I'll just make it a sub routine for anytime I am quick saving the form.

  10. #10
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    Looks good. Pay attention to data types on your variables. Good luck

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

Similar Threads

  1. Default value on an unbound combo box
    By lsmcal1984 in forum Forms
    Replies: 1
    Last Post: 10-10-2013, 06:40 AM
  2. Replies: 1
    Last Post: 04-10-2013, 12:47 PM
  3. Unbound Combo Box to filter form
    By Firefighter22 in forum Forms
    Replies: 4
    Last Post: 08-31-2011, 03:39 PM
  4. using unbound combo box to filter report
    By jlclark4 in forum Reports
    Replies: 1
    Last Post: 01-25-2011, 04:12 PM
  5. Capture 2nd Value in an unbound Combo.
    By sesproul in forum Forms
    Replies: 5
    Last Post: 04-30-2010, 02:07 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