Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Form For Adding Records - Prob w/ Clicking Elsewhere on Form
Message
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Titre:
Form For Adding Records - Prob w/ Clicking Elsewhere on Form
Divers
Thread ID:
00122835
Message ID:
00122835
Vues:
52
In making frmAddRec for adding Employee Absentee Data, I have the following ...

To make it convenient for how a user wishes to lookup & select an employee on whom to work ...

cboEmpNo - for Selecting by Employee # to Add Record for that employee
RowSource=Prlink.nmbr,lname,fname

cboEmpName - for Selecting by Employee Name to Add Record for that employee
RowSource=Prlink1.lname,fname,nmbr

NOTE: Prlink & Prlink1 are aliases for the same table (one ORDERed by TAG nmbr, the other ORDERed by TAG name).

On the remainder of the form I have ...

- A lblName where I display the selected employee's name in a relatively big font.

- A couple of text boxes displaying additional information about the selected employee (ControlSource is from Prlink.dept & Prlink.dateofhire).

- Text boxes with ControlSource from the Absentee table (Abs.dbf). These provide the fields on the form into which the user makes input. No relation has been set between Prlink & Abs for this form because the only thing I'm ever doing on this form is appending a blank record and letting the user fill it in -- I'm using the INSERT command and inserting the needed values from Prlink into Abs (INSERT INTO Abs (nmbr) VALUES (Prlink.nmbr).

- cmdOK - Error checks for omitted field input and "Clears" form by moving tables to EOF() and SetsFocus to cboEmpNo.

- cmdCancel - Deletes added record and "Clears" form by moving moving tables to EOF() and SetsFocus to cboEmpNo.

- cmdQuit - Error checks for omitted fields and Releases Form.

In the Init Event of the Form I place Prlink @ EOF() so that no data is shown in form before user has the opportunity to make a selection from the combo boxes.

I also programmatically disable all items on the form except for cboEmpNo, cboEmpName & cmdQuit.

My GOAL is to not allow the user to be able to get inside any item on the form other than the selection combo boxes, until he has made a selection from one of the combo boxes. Then once the user has made a selection, the goal is to not allow access back into the combo boxes until the record is filled in.

I have placed the following code in cboEmpNo.Valid:
SELECT Prlink
PUBLIC mvar1
mvar1=This.DisplayValue
SEEK mvar1

*Errortrap for Invalid Emp No.
IF EOF()=.T.
	ThisForm.cboEmpName.DisplayValue=""
	ThisForm.lblName.Caption=This.DisplayValue +" is not a Valid Emp No."
	This.DisplayValue=""
ELSE
	ThisForm.Refresh()
	*Display lname in Combo2
	ThisForm.cboEmpName.DisplayValue=Prlink.lname	
	
	*Display Employee Name on form
	ThisForm.lblName.Caption= ;
		ALLTRIM(prlink.fname)+" "+ ;
		ALLTRIM(prlink.lname)

	INSERT INTO Abs (nmbr) VALUES (Prlink.nmbr)
	
	*Disable Combo Selection boxes until this
	*record is filled in.
	This.Enabled=.F.
	ThisForm.cboEmpName.Enabled=.F.
	
	ThisForm.cmdOK.Enabled=.T.
	ThisForm.cmdCancel.Enabled=.T.
       User input items on the form are also enabled.

ENDIF
The PROBLEM that has shown up in my testing of how failsafe the form is, is that as soon as the Form is initialized and displays on screen, I can click inside one of the other items on the form, and cboEmpName.Valid is firing. For some reason, at this point, Prlink is no longer at EOF(), and lblName and other items with their ControlSource being from Prlink are being updated and displayed, and, of course, a new record gets INSERTed.

It seems to me that a data input form of this sort shouldn't be a very complex thing to do with VFP, but am I going about it in the right manner? I'm really stumped. Help would be greatly appreciated.
Chuck Henry
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform