473,320 Members | 1,838 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Reset Combo Box entry?

17
Hello !

Could someone please help me with this?

I have a ComboBox named cboSTATUS with a limited Value List, bound to Col1.. Values : "Yes";" No";" Completed"
The selected Value is stored in fldSTATUS in tblONE.

I have Validations which act on the selection in cboSTATUS, and they work fine.

My Question is: if a Validation doesn't pass, I want the User to return to cboSTATUS and have the Selection change to "No".

Here is an example of the validation code:
---------------------------------------
1. If IsNull(Me.CAI) Or Me.CAI = "" And Me.Status = "Completed" Then
2. MsgBox "If you have put Status as 'Completed'" & vbCrLf & _
3. "Then you must enter the Author's CAI" & vbCrLf & _
4. "Please either review your CAI entry or reset Status", vbCritical, "CAI Validation"
5. Cancel = True
'Want to Go to cboSTATUS here? and reset it to value "No"
6. Exit Sub
---------------------------------------
Many thanks !
AMBLY
Jun 12 '07 #1
9 7510
JConsulting
603 Expert 512MB
Hello !

Could someone please help me with this?

I have a ComboBox named cboSTATUS with a limited Value List, bound to Col1.. Values : "Yes";" No";" Completed"
The selected Value is stored in fldSTATUS in tblONE.

I have Validations which act on the selection in cboSTATUS, and they work fine.

My Question is: if a Validation doesn't pass, I want the User to return to cboSTATUS and have the Selection change to "No".

Here is an example of the validation code:
---------------------------------------
1. If IsNull(Me.CAI) Or Me.CAI = "" And Me.Status = "Completed" Then
2. MsgBox "If you have put Status as 'Completed'" & vbCrLf & _
3. "Then you must enter the Author's CAI" & vbCrLf & _
4. "Please either review your CAI entry or reset Status", vbCritical, "CAI Validation"
5. Cancel = True
'Want to Go to cboSTATUS here? and reset it to value "No"
6. Exit Sub
---------------------------------------
Many thanks !
AMBLY


How about

Expand|Select|Wrap|Line Numbers
  1.  
  2. me.cboStatus = "no"
  3.  
  4. or
  5.  
  6. me.cboStatus = me.cboStatus.itemselected(1)
  7.  
  8.  
J
Jun 12 '07 #2
AMBLY
17
Hi J

Thanks for your reply..

If I make it:
5. Cancel = True
6. Me.cboStatus = "No"

then it Cancels fine, but just ignores Line 6 and doesn't change the entry in cboStatus at all.

Is is because cboStatus is a closed Value-List Combo Box?

Because, if I test by making line 6. act on a 'normal' a txtBox (say txtABC) which is linked directly to the table, it does do the action, and changes or makes, txtABC = "No".

If I make Line 6. your other suggestion, I get a Compile error on the line, and highlighting the .itemselected bit...? Sorry If I've misunderstood something!

Cheers
AMBLY
Jun 12 '07 #3
JConsulting
603 Expert 512MB
Hi J

Thanks for your reply..

If I make it:
5. Cancel = True
6. Me.cboStatus = "No"

then it Cancels fine, but just ignores Line 6 and doesn't change the entry in cboStatus at all.

Is is because cboStatus is a closed Value-List Combo Box?

Because, if I test by making line 6. act on a 'normal' a txtBox (say txtABC) which is linked directly to the table, it does do the action, and changes or makes, txtABC = "No".

If I make Line 6. your other suggestion, I get a Compile error on the line, and highlighting the .itemselected bit...? Sorry If I've misunderstood something!

Cheers
AMBLY

Change Itemselected to ItemData. item 0 would be the first one in the list...item 1 would be the second, etc...

Example
Expand|Select|Wrap|Line Numbers
  1. Me.Combo38 = Me.Combo38.ItemData(1)
  2.  
Should do it.
J
Jun 12 '07 #4
AMBLY
17
Hi J

I'm guessing you've tested in some way? - but sadly, this doesn't work for me either!

It again goes to Compile error on .ItemData :
5. Cancel = True
6. Me.cboStatus = Me.cboStatus.ItemData(2)

Hmmm! ? I'm sure it's something to do with it being a ComboBox with a " Value.List bound to Col1" - but that's as far as I can figure:-)


Cheers
AMBLY
Jun 12 '07 #5
JConsulting
603 Expert 512MB
Hi J

I'm guessing you've tested in some way? - but sadly, this doesn't work for me either!

It again goes to Compile error on .ItemData :
5. Cancel = True
6. Me.cboStatus = Me.cboStatus.ItemData(2)

Hmmm! ? I'm sure it's something to do with it being a ComboBox with a " Value.List bound to Col1" - but that's as far as I can figure:-)


Cheers
AMBLY

Hi Ambly,
Yes, I tested with a combo box configured with a Value List.

Are you able to test as well?

Try creating a blank form. Put a combo box on it and a button.

Add items as a value list to your combo box.

Put the code to set the ItemData(1) on the button.

Then click the button.

Let me know if it works.

This may have to do with the Cancel = true statement too.

J
Jun 13 '07 #6
AMBLY
17
Thanks J
I will try that and come back...

Meantime I discovered something regarding your other initial suggestion..

If I try (and it makes no odds if the Cancel - True bit is before or after it)
Me.cboStatus = "No"
Cancel = True


Then, in the change to cboStatus does happen! but, 'behind the curtain'......ie: I have cbostatus as "Complete" and a field deliberately set with 'bad data'...I run the Save and trigger the validation code with that bit above in it, and it fails because of the bad data , as expected....

And, the record 'looks' like it has not actioned the line of code to make cboStatus to "No", (ie it still displays "Complete") BUT, actually if I do nothing, don't touch cboStatus, and don't correct the 'bad fiekl' then immediately Save again, no Invalid data is detected (the clue!) And if I then reopen the record, walla! There is cboStatus set at "No". But it took a close and reopen of the record to make it appear as "No" on the form record......so clearly at the time of the FIRST Save, cboStatus had been reset to "No" but not visibly so.....?

Which doesn't mean I know why :-))

Cheers
AMBLY
Jun 13 '07 #7
JConsulting
603 Expert 512MB
Thanks J
I will try that and come back...

Meantime I discovered something regarding your other initial suggestion..

If I try (and it makes no odds if the Cancel - True bit is before or after it)
Me.cboStatus = "No"
Cancel = True


Then, in the change to cboStatus does happen! but, 'behind the curtain'......ie: I have cbostatus as "Complete" and a field deliberately set with 'bad data'...I run the Save and trigger the validation code with that bit above in it, and it fails because of the bad data , as expected....

And, the record 'looks' like it has not actioned the line of code to make cboStatus to "No", (ie it still displays "Complete") BUT, actually if I do nothing, don't touch cboStatus, and don't correct the 'bad fiekl' then immediately Save again, no Invalid data is detected (the clue!) And if I then reopen the record, walla! There is cboStatus set at "No". But it took a close and reopen of the record to make it appear as "No" on the form record......so clearly at the time of the FIRST Save, cboStatus had been reset to "No" but not visibly so.....?

Which doesn't mean I know why :-))

Cheers
AMBLY
could be a refresh isssue with the form actually now that I think of it.

The cancel action should put you back to the form with the cursor in the combo box...at least in theory. Setting the value then sticking you back in there might be causing the problem.

How about sticking a me.refresh in after the cancel? Just for giggles.

Setting the value of the combo is the easy part....contending with other events is proving to be a challenge. no?
J
Jun 13 '07 #8
AMBLY
17
Well J :-))

You got the last laugh !

Me'Refresh duly added...

and cboStatus duly and visibly = No!

Yipee! Amazingf what 2 words and a dot will do...(Gee, the things that make us rejoice..........)
Thanks a million and for sticking with it
Happy AMBLY


Now, since I have a captive audience, if you have a mo, would you mind taking a peek at this one:
http://www.thescripts.com/forum/thread656700-AMBLY.html

at just the bottom part, my last 'reply' and see if you can help me with that one, it's driving me potty, I'd be ever so grateful!
A.
Jun 13 '07 #9
JConsulting
603 Expert 512MB
Well J :-))

You got the last laugh !

Me'Refresh duly added...

and cboStatus duly and visibly = No!

Yipee! Amazingf what 2 words and a dot will do...(Gee, the things that make us rejoice..........)
Thanks a million and for sticking with it
Happy AMBLY


Now, since I have a captive audience, if you have a mo, would you mind taking a peek at this one:
http://www.thescripts.com/forum/thread656700-AMBLY.html

at just the bottom part, my last 'reply' and see if you can help me with that one, it's driving me potty, I'd be ever so grateful!
A.
Glad we got this one working...I can sleep now :)
I commented on your other question too.
J
Jun 13 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: James | last post by:
I am used to VB6 but need to develop something in .Net. I need to create several bound combo-boxes which will use lookup tables to get their values. I created a form using the dataform wizard....
1
by: Jason Northampton | last post by:
Hello This is the first time I've used a discusion forum and up until now I have managed to use and or modify VB code from the various sites on the web, until now! This is a simple problem and I...
3
rhitam30111985
by: rhitam30111985 | last post by:
Hi all.. i am trying to create a combo with the pop down list being modfied in real time as i type each character : import gtk window=gtk.Window(gtk.WINDOW_TOPLEVEL)...
4
by: AXESMI59 | last post by:
have a project in which I am entering Serial Numbers and Date codes into a Combo box. Serial numbers are all different. However, they could each have the same Date Code. Each Serial Number has a...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.