I've got a strange problem using VB to connect to a mysql database via ODBC.
The problem isn't with connecting, but rather with one particular control --
the "datalist/combo" control.  In fact, the "problem" doesn't seem to have
anything to do with databases directly, BUT I figured that there is
sufficient VB "talent" on this list that someone has seen this and knows how
to "fix" it.  (indirectly, I'm not able to reliably detect if a row exists
or not using this control)

Background: the "datacombo" control will automatically load itself with
values taken from a dataset -- this is really cool for "lookup" fields where
you want to make it easy for the end user to select related data.  Being a
"combo" type item, it ALSO allows the user to type in a completely NEW
value, and that's where things seem to go downhill.

In particular, the control has a property/field called "macthedwithlist"
which returns true if the user selects or types in a value actually in the
list, and another property called "selecteditem" which returns a "bookmark"
[record number] of the selected value.  This bookmark can then be applied to
the related dataset to retrieve the full record for display or editing.  The
problem I'm running into is that if you TYPE IN the value directly (i.e.,
without using the mouse to point-n-click or the arrow keys to scroll through
the list), the "bookmark" contains a "null" value EVEN IF THE USER TYPES IN
A MATCHING ENTRY.  (and here, a "null" bookmark would imply that the entered
value doesn't match anything)

What I'm trying to accomplish is to combine two activities into one logical
activity -- for example, "inventory item maintenance".  I want to build a
form that allows editing of all the particulars for an inventory item (item
code, description, qty, etc.)  There are two (well, three) activities that
can occur: a new item can be added, or an existing item can be modified (or
deleted).

The "traditional" way to do this would be to place an "add" button on the
form to clear the form and allow an item to be defined, generating an
annoying error if the user enters an existing "code" number.  Likewise, you
would place a "find" button that generates an equally annoying error if you
DON'T type in the proper item code.  What I want to do is combine these
activities via the "combo" box -- if you select a existing item the form
displays the data and allows for modifications.  Likewise, if you type in a
new value, the program implicitly "adds" a new (blank) record -- note that
since I've determined from the "key" value entered whether to add or modify
an entry, there is no need to display an "annoying error".

The part my program falls over on is that if you TYPE in an EXISTING item
code, the two tests that you can perform to see if this is a "new" entry
generate conflicting values: "matchedwithlist" will return TRUE (meaning we
should MODIFY the entry), and "selecteditem=null" also returns TRUE (which
would indicate we need to ADD a new entry...)


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to