question

GlennWalker-1236 avatar image
0 Votes"
GlennWalker-1236 asked GlennWalker-1236 answered

Combobox properties

I want to be able to input an item into a combobox that is data bound. If this is possible.

I have a combobox that is bound to a table. I use this combobox to display a set of items from a table, each of which defines a type of document, e.g., SOP, Drawing.

                 cboDoc.Enabled = True
                 cboDoc.TabIndex = 2
                 cboDoc.TabStop = True
                 cboDoc.DataSource = DocBindingSource
                 cboDoc.ValueMember = "DocType"
                 cboDoc.DisplayMember = "DocType"

With the above property settings this combobox allows the user to select one of the document types to later input into a record.

What I want to do, in addition to this is two things. The first is for the user to be able to input a value to the record. The properties, as set, already allow for this.

The second is to be able to save the input string value back into the table bound to the combobox.

I have not been able to uncover how this is done with my current review of material and/or queries.


vs-general
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

GlennWalker-1236 avatar image
0 Votes"
GlennWalker-1236 answered

OK, I have a working solution for saving an input to bound combobox table. While it works, and I will find myself a better handler, I really believe that there must be a better way than that. It seem so.... klugey.

Anyway, with this I am able to add items to lkpDoc from the Combobox.


     Private Sub AddDocType_Click(sender As Object, e As EventArgs) Handles cboDoc.Leave
         Dim CurrentRecord = 0
         MasterBase.AddParam("@doc", cboDoc.Text)
         MasterBase.MasterBaseQuery("INSERT INTO lkpDoc (DocType) " &
                                    "VALUES (@doc); ")
         CurrentRecord = MasterBase.ListTable.Rows.Count - 1
         MasterBase.AddParam("@doc", cboDoc.Text)
         MasterBase.AddParam("@recno", CurrentRecord)
         MasterBase.MasterBaseQuery("UPDATE lkpDoc " &
                                    "SET DocType=@doc " &
                                    "WHERE ID=@recno ")
         'Report & Abort on errors
         If NoErrors(True) = False Then Exit Sub
     End Sub
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

vb2ae avatar image
0 Votes"
vb2ae answered
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

GlennWalker-1236 avatar image
0 Votes"
GlennWalker-1236 answered

I don't think so, but I could be. My problem is just as soon as I think I understand comboboxes I find that I actually know nothing. Here is where I am at so far:

This is what I have kluged together so far. Kind of works, but I end up with two additions to the lkpDoc table. A work in progress.

     Private Sub AddDocType_Click(sender As Object, e As EventArgs) Handles cboDoc.Leave
         Dim RecordCount = 0
         MasterBase.AddParam("@doc", cboDoc.Text)
         MasterBase.MasterBaseQuery("INSERT INTO lkpDoc (DocType) " &
                                    "VALUES (@doc); ")
         RecordCount = MasterBase.ListAdapter.Fill(MasterBase.ListTable)
         MasterBase.AddParam("@doc", cboDoc.Text)
         MasterBase.MasterBaseQuery("UPDATE lkpDoc " &
                                    "SET DocType=@doc " &
                                    "WHERE ID=RecordCount ")
         'Report & Abort on errors
         If NoErrors(True) = False Then Exit Sub
     End Sub
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.