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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combobox with RowSourceType= 1 1

Status
Not open for further replies.
Jan 20, 2007
237
US
Hi everyone,
Would like to know,if i can show in this combobox, when i gets focus by default the following value ('Mach Serial#')
and be able to press enter and once, i have pressed enter to Enable a txtbox(txtjobno), to enter the serial number, the name of the comboxbox = cbojobno

combobox code in the init event see below

Code:
With This
	.RowSourceType= 1
	.AddListItem('Mach Serial#')
	.AddListItem('\-')
	.AddListItem('\Non Serial#')
	.AddListItem("89741")
	.AddListItem("89744")
	.AddListItem("89760")
	.AddListItem("89736")
	.AddListItem("13100")		
	.Style= 2
	.ListIndex=0
ENDWITH
the code i have in the cbojobno interactive event is as follow
Code:
Local lcJobNo
lcJobNo = Alltrim(This.DisplayValue)
With This.Parent
	.txtJobNo.Visible = .F.
	.txtJobNo.Value = 0
	.cbowtype.Enabled = .F.
	.cboDescription.Enabled = .F.
	.chksheet.enabled = .f.
		
	Do Case
		Case m.lcJobNo = "89741"
			.cbowtype.Value = 'Miscellanous Assemby'
			.cboDescription.Value = 'Misc Assembly'
			.txtextradesc.Enabled = thisform.cmdAbort.Enabled 
		Case  m.lcJobNo = "89744"
			.cbowtype.Value = "Assembly (Regular)"
			.cboDescription.Value = "Miscellaneous Sample print"
			.txtextradesc.Enabled = thisform.cmdAbort.Enabled 
		Case m.lcJobNo = "89760"
			.cbowtype.Value = "Assembly (Regular)"
			.cboDescription.Value = "Ptod, Holidays, etc"
			.txtextradesc.Enabled = thisform.cmdAbort.Enabled 
		Case m.lcJobNo = "89736"
			.cbowtype.Value = "Assembly (Regular)"
			.cboDescription.Value = "R & D Miscellaneous"
			.txtextradesc.Enabled = thisform.cmdAbort.Enabled 
		Case m.lcJobNo = "13100"
			.cbowtype.Value = "Assembly (Regular)"
			.cboDescription.Value = "STANDARD"
			.txtextradesc.Enabled = thisform.cmdAbort.Enabled 
		OTHERWISE 				
			.txtJobNo.Visible = .T.
			.txtJobNo.Enabled = .T.			
			.cbowtype.Enabled = .T.
			.cboDescription.Enabled = .T.
			.txtextradesc.Enabled = thisform.cmdAbort.Enabled 			
			.cbowtype.Value = "Assembly (Regular)"
			.cboDescription.Value = ''  && None yet, let them select
			.chksheet.enabled = .t.
			.txtJobNo.SetFocus
	ENDCASE
	
	If Alltrim(This.DisplayValue) <> 'Mach Serial#'   &&'Others'  
		Thisform._sheetrefresh()
	Endif

Endwith
i am able to display in the combobox by default the value ='Mach Serial#' as i put code in the gotfocus, but i am not able when selecting that value in the combobox, to enable the txtjobno, to imput a value there, any help very very appreaciated besides of learning a trick thanks in advance
 
To display 'Mach Serial#' by default, you just need to set .ListIndex to 1 (in the Init) rather than zero.

To fill in the textbox, the easiest way is simply to call THIS.InteractiveChange from the Init (after the code that you showed).

Personally, I would go one step further. Put the InteractiveChange code in a custom method, and call that method from both the Init and the InteractiveChange. But that's not essential. You can do it the way I suggested above if you prefer.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Mike,
as always thanks so much for the teaching, that really works but before you answered, i put the same thing on my ADD button click event, both methods works, if you have any advise, what i should not use it on the Add cmd button click, please share your thoughts
again thanks
 
Glad it worked.

I think the choice between the Add button and your original method is one of user convenience. Giving them a specific button to achieve the effect is probably a better choice, but I can't really judge that as I am not familiar with the overall layout of the form. I suggest you do whichever seems more natural to you.

By the way, do you have a good reason for making the Job No. invisible when the user selects a specific number? In general, I prefer to disable controls rather than hiding them in cases like this. But that's just my personal choice.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
By the way, do you have a good reason for making the Job No. invisible when the user selects a specific number? In general, I prefer to disable controls rather than hiding them in cases like this. But that's just my personal choice.

Well if you look into the init, you will see that i have the numbers below, which are fixed numbers in the combobox, so once they select those, you can see in the interactive(), that i will fill in the form, others values by default depending of the numbers selected but the one called .AddListItem('Mach Serial#'), will bring the txtjobno to popup for them to enter a different jobno than the one listed below and that will also allow the .cbowtype.Value = "Assembly (Regular)" to popup as that default value on that other combobox but they can select from that combobox other values instead of the default, while using the predefined as "Non Serial#", will fill the rest of the values w/o users interface,then just "save" that entry.
Thanks a lot

Code:
.AddListItem('\Non Serial#')
	.AddListItem("89741")
	.AddListItem("89744")
	.AddListItem("89760")
	.AddListItem("89736")
	.AddListItem("13100")
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top