>
> Actually this should be self."RegID".PositionValue=0. Position returns or
> sets the position of the control on the form whereas PositionValue selects
> the index value of the Choices. This works only if the PositionValue being
> set is different from the value that is already there. As the values that
> appear when a new record is created are the correct default values I want
> to keep them. I have run through everything several times and my original
> analysis holds, the values in the Dropdown Lists are not being picked up
> for inclusion in the INSERT statement.
I have several Dropdown list on my forms. They work correctly. However, I
set the value. It actually is a problem because it causes the "do you want
to save" dialog to appear even if I make no other changes to a new() record.
> Before I go any further I want to make I understand SaveNewUnchanged. If it
> is set to False (the Default setting) , when one saves a new record only
> the field values in the ui that were entered by hand or changed are saved.
> If it is set to True all values in a new record are saved. Even though I
> have SaveNewUnchanged = True it is acting like =False. In other words
> though the values for each Dropdown List is set it not being picked up the
> process the builds the INSERT query. At this point I know this is what is
> happening or not happening as the case may be. I would suggest creating a
> test form with Dropdown lists and try it for yourself.
> Furthermore I am not sure I believe that there is no interaction between
> the control and the database in regards to default values, at least for
> Dropdown Lists. If I do not have the database default value as one of the
> Choices or Keys then I get the error- 'ValueError: String must be present
> in the choices.' when I create a new record.
Take Larry's suggestion and change one of the default values on the back to
something crazy and see if it appears.
> This is before I do anything
> with the record. The behavior of the DropDown List when you create a new
> record is the same as when you navigate through existing records, the
> displayed value and the control property Value are both equal to the
> database value. In the case of a new record this is the database default
> value for the column, unless the Choice or Key lists don't have the value
> in which case the value is PositionValue=0. This is the same behavior
> observed when navigating existing records. By the way I regard this as a
> bug as it leads the user to thinking they are looking at the actual value
> for the field when in fact they are not. The error output to the terminal
> shows the ValueError mentioned above , however it is not propagated to the
> ui. Again set up a test form and see what happens, I know what I am
> seeing.
I did. I can not validate your results. It does not mean you are wrong just
that you are mostly like doing something different.
> As to the constraint issues, they are after the fact issues. They occur
> because the INSERT statement is not supplying the necessary values to the
> database. Yes, I can and have (see my previous posts) run the new()
> procedure without constraints. It was successful in that the INSERT
> succeeded but failed in that it did not INSERT all the values from the form
> record to the database record.
Like you I'm more concerned about the insert not working. But after removing
the contraints the insert worked. At least you now know that the PK is
working correctly because the insert works. Next I would add back the
constraints one at a time. When you get an error consider what is required
to make it work correctly with the insert. You then have several choices to
work with the data.
def validateField(self,fld,val):
ret = ""
if fld:
...
The above will work with the lostfocus of the control.
def validateRecord(self):
""" Hook for subclass business rule validation code.
This is the method that you should customize in your subclasses
to create checks on the data entered by the user to be sure that it
conforms to your business rules. Your validation code should return
an error message that describes the reason why the data is not
valid; this message will be propagated back up to the UI where it can
be displayed to the user so that they can correct the problem.
Example:
if not myNonEmptyField:
return "MyField must not be blank"
Or you could subclass beforeSave()
or do something in the backend.
On my forms I use the first two.
...
--
John Fabiani
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/dabo-users/[EMAIL PROTECTED]