INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Combobox with RowSourceType= 1

Combobox with RowSourceType= 1

(OP)
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

RE: Combobox with RowSourceType= 1

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

RE: Combobox with RowSourceType= 1

(OP)
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

RE: Combobox with RowSourceType= 1

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

RE: Combobox with RowSourceType= 1

(OP)

Quote:

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") 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close