By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,627 Members | 1,870 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,627 IT Pros & Developers. It's quick & easy.

Case statement to change a row source

100+
P: 462
I would like to use a case statement to change the row source in a form. The row source would change depending on a variable that can also change.
if the variable contains the words "Wild Group" then the row source would change, if it didn't then it would be something else.
I tried an If statement but it didn't like the Like "*Wild Group*"
Expand|Select|Wrap|Line Numbers
  1. If VWGName like "*Wild Group*" then
  2.  
Any help would be appreciated.
Thanks
Feb 16 '15 #1

✓ answered by NeoPa

FYI Like is supported by both SQL and VBA.

Share this Question
Share on Google+
5 Replies


Seth Schrock
Expert 2.5K+
P: 2,951
Forms don't have a Row Source property. It does have the Record Source property.

Anyway, I don't think that Like is a VBA keyword like it is in SQL. Try the following:
Expand|Select|Wrap|Line Numbers
  1. If InStr(VBGName, "Wild Group") > 0 Then
Feb 16 '15 #2

100+
P: 462
I was able to figure it out. I should probably work a little longer before posting a question. Thanks for your reply.
Feb 16 '15 #3

NeoPa
Expert Mod 15k+
P: 31,769
FYI Like is supported by both SQL and VBA.
Feb 18 '15 #4

Seth Schrock
Expert 2.5K+
P: 2,951
I didn't know that. Thanks for the FYI NeoPa!
Feb 18 '15 #5

NeoPa
Expert Mod 15k+
P: 31,769
No worries Seth. I was telling my son only today that VBA (and SQL) comparisons are much more flexible than a single wildcard character. In fact care must be taken when using Like if the data has '[' characters in it such as Fields and Objects often do within SQL.

For instance, a field name in a table could be [A B]. Search for that within a Like string and you'll match any single character of A, B or space. Powerful, but confusing for the unwary.
Feb 18 '15 #6

Post your reply

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