Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combo Box question 2

Status
Not open for further replies.

ezpzjohn

Programmer
Jun 29, 2001
50
GB
Hi

I have a data entry form which contains, amongst other things, a combo box and a "New" command button. When the user clicks on New, a BEGIN TRANSACTION is issued and an APPEND BLANK.

The combo box allows the user to enter a new code (Primary Key). The data for the combo box is a list of existing codes. What I want to happen, is when the code is entered we search to see if the code already exists and updates the blank record with the code if it doesn't.

The problem with a combo box seems to be that if the code entered is not in the existing list, the code is reset to blank.

Any ideas how to get around this?

John
 
Hi

My comments...
**********************************************************
" When the user clicks on New, a BEGIN TRANSACTION is issued and an APPEND BLANK."... is not the correct way.

I would always advice that between the BEGIN transaction and an END transaction, there shall be no user input. OR else, soonere one user is going to lock up another user an the software package will fail in that the users cannot enter simulataneously.

Think of using Buffering. You can use a Table buffer conveniently, if you are using an updatable view. So you can keep moving around and then update the record you want in the underlying table with a TABLEUPDATE(). If you use a table buffering in a Table directly, you may end up locking the table again. I suggest in that case a ROW buffer.

You can always open the same table twice... one in READ only mode.. and used for lookup and the same table opened again an the records are strictly moved with proper TABLEUPDATE().
***********************************************************
Now given the above question, without the above advice...
but suggestion for your problem...
You can open the table again or a view for this purpose (What I mean.. is USE myTable ORDER myOrder AGAIN IN 0 ALIAS myAlias2). This myAlias2 can become the source for the combo box and can be scrolled. And this table can be used to populate what ever you want in the Appended Blank record of the form.

Hope this helps you :)
ramani :-9
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
I had a similar problem with the Combobox control because I was using the Value property rather than Text property. If your combo box name is cboMyCode. When making your search or replacement use the Text property rather than the Value property meaning:
=====================================
seek(alltrim(thisForm.cboMyCode.TEXT))
if eof()
append blank
replace myCode with alltrim(thisForm.cboMyCode.TEXT)
......
endif
=======================================
My understanding is that when the text that you key in does not match any value of your record source the value returned is blank.

if this does not answer your question, forgive me I am just a rookie, but if it does make sure you take into consideration Ramani's comments


 
Thanks to both Ramani and Zady, your advice was really helpful. I have one more question that follows on from Ramani's advice about updatable views.

I understand the concept of using views and using them to update an existing record, but I want a data entry form that will allow a user to edit an existing record or add a new one. If I was using a view to edit a record, the fields on my form would be the fields from the view, but what are they if this is a new record?

What I mean is, I would rather not append a blank record until the user clicks the Save button, so how do I get my fields to be blank with a view? The way I have been doing it is to do a BEGIN TRANSACTION with an APPEND BLANK and then a ROLLBACK if the user decides not to add the record. I can certainly see why, in a network scenario, this is not a good idea.

Any comments would be really welcome.

John
 
Hi John,

The view can be the complete table, not necessarily one record.

You can append blank to a view.. Basicaly, view is an artificial table as for as you are concerned. If the view is built on conditions of matching some variable to a field, the view rows are built from the table matching those conditions. Once the view is built, you can still append a blank. The conditions are only to fetch the initial collection of records.

SO if the view is updatable, a TABLEUPDATE() updates the concerned table.

Hope this helps you :) ramani :-9
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
Thanks Ramani. That helps a lot. I will do some experimenting.

John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top