VBA code to check data in form

paultje_bos

New Member
Joined
Oct 20, 2014
Messages
39
All, I have another challenge. I have a form in which people have to enter content of a container. They can highlight the container as WASTE, but then they have to enter waste in the content as well and put in the remarks field WASTE. What I need is a code that checks if there is one or more rows with the remark WASTE if WASTE is selected. If not, it should give you a message with something like "You select the container as WASTE, but no waste is inside the container. Please put Waste in remarks for the applicable lines".

I hope I make sense to you, of not please let me know.
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
maybe conditional format for the range

format only cells with > specific text > containing > waste

and give it a colour

it might be extended to a row or other uses
 
Upvote 0
why not set the other applicable fields to 'waste' if the key field is designated as waste, or all applicable fields if even one has been designated as waste? However, if it is possible that additional comments have been entered when this check is run, those comments could be arbitrarily altered to 'waste' during such an update. You'd have to code to either prepend or append the word to the existing comment. Assuming no issues updating the record, something like
Code:
If ctl1 = "waste" OR ctl2 = "waste" OR ctl3 = "waste" Then
  With Me
    .ctl1 = "waste"
    .ctl2 = "waste"
    .ctl3 = "waste" 
    .Requery  
  End With
End If
To prepend to a particular field (ctl2), Dim a variable, assign the control value to it then have
.ctl2 = "Waste: " & strVariable
 
Upvote 0
Ignore my response, thought I was in the excel section
 
Upvote 0
It does seem a little redundant to make people enter "waste" three times (?). Not very efficient data entry.
 
Upvote 0
The fact is that inside the container there can be more content than waste, but because we need to have at least one waste item (due to other linked programs) I want to have a check. But I used the idea from Mole999, it is not exactly what I was looking for, but I think it will do the job. Thanks all for the input!
 
Upvote 0

Forum statistics

Threads
1,221,814
Messages
6,162,135
Members
451,744
Latest member
outis_

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top