PC Review


Reply
Thread Tools Rate Thread

Ensuring Combobox has Value entered if another ComboBox has aspecific value

 
 
Gareth Hardman
Guest
Posts: n/a
 
      8th May 2012
Hi,

I am new to this group and reletavily new to VBA code and Userforms so
please forgive my potential huge knowledge gaps...

I am trying to ensure that if one particular combobox has a value i.e.
'Breach' in it, that before the form can be 'submitted' successfully
another combobox has a value in it. I feel I maybe close with the
code below (but I could be a million miles away as well!):

I am attempting to use code like:

'check for DPA 1st Box
If Trim(Me.DPA.Value) = "" Then
Me.DPA.SetFocus
MsgBox "Please enter whether DPA was successful or not",
vbExclamation, "Not Quite Complete..."
Exit Sub
End If

' Check DPAIF Box
If Trim(Me.DPA.Value) = "Breach" Or "Process Fail" Then
If Trim(Me.DPAIFBox.Value) = "" Then
Me.DPAIFBox.SetFocus
MsgBox "Please select a reason why DPA was not completed successfully"
Exit Sub
End If

I am getting the error message: "Compile Error: Block IF without End
IF"

If the first DPA combobox says "Yes" or "N/A" then it is not essntial
that the DPAIFBox has a value. Hope all this makes sense.


Help would be grately appreciated - and I apoloigise if I have not
conformed to any forum etiquette
 
Reply With Quote
 
 
 
 
Auric__
Guest
Posts: n/a
 
      8th May 2012
Gareth Hardman wrote:

> I am new to this group and reletavily new to VBA code and Userforms so
> please forgive my potential huge knowledge gaps...
>
> I am trying to ensure that if one particular combobox has a value i.e.
> 'Breach' in it, that before the form can be 'submitted' successfully
> another combobox has a value in it. I feel I maybe close with the
> code below (but I could be a million miles away as well!):
>
> I am attempting to use code like:
>
> 'check for DPA 1st Box
> If Trim(Me.DPA.Value) = "" Then
> Me.DPA.SetFocus
> MsgBox "Please enter whether DPA was successful or not",
> vbExclamation, "Not Quite Complete..."
> Exit Sub
> End If
>
> ' Check DPAIF Box
> If Trim(Me.DPA.Value) = "Breach" Or "Process Fail" Then
> If Trim(Me.DPAIFBox.Value) = "" Then
> Me.DPAIFBox.SetFocus
> MsgBox "Please select a reason why DPA was not completed successfully"
> Exit Sub
> End If


Need another "End If" right here.

> I am getting the error message: "Compile Error: Block IF without End
> IF"
>
> If the first DPA combobox says "Yes" or "N/A" then it is not essntial
> that the DPAIFBox has a value. Hope all this makes sense.
>
>
> Help would be grately appreciated - and I apoloigise if I have not
> conformed to any forum etiquette


--
That would be a bug that needs to be found, not strangled to death.
 
Reply With Quote
 
 
 
 
Gareth Hardman
Guest
Posts: n/a
 
      9th May 2012
Hi Auric,

I have tried adding an additional End IF statement, however I now get
a 'Runtime Error 13: Type mismatch' error message. When I select
Debug, it highlights the folowing line of code in yellow:

If Trim(Me.DPA.Value) = "Breach" Or "Process Fail" Then

Any further help on this would be grateful
 
Reply With Quote
 
Gareth Hardman
Guest
Posts: n/a
 
      9th May 2012
On May 9, 8:09*am, Gareth Hardman <(E-Mail Removed)> wrote:
> Hi Auric,
>
> I have tried adding an additional End IF statement, however I now get
> a 'Runtime Error 13: Type mismatch' error message. *When I select
> Debug, it highlights the folowing line of code in yellow:
>
> If Trim(Me.DPA.Value) = "Breach" Or "Process Fail" Then
>
> Any further help on this would be grateful


Hi - I have now found a solution to the query - thanks for looing into
it for those that may have
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Complex excel - calling formulae result and setting as value of aspecific cell Michael Harris Microsoft Excel Discussion 1 9th Nov 2009 11:18 PM
Interesting problem in excel, producing a list for aspecific date mark Microsoft Excel Misc 3 17th Aug 2009 10:56 PM
Ensuring Correct Vin Number is entered Rocko Microsoft Excel Misc 2 2nd Jul 2009 07:55 AM
how can i avoid the postback (or ignore it) when not originated by aspecific button tiago.private@gmail.com Microsoft ASP .NET 4 17th Nov 2008 06:01 PM
Ensuring values in a subform are entered correctly =?Utf-8?B?Um9uIEEu?= Microsoft Access Forms 3 10th Jun 2007 11:14 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:33 AM.