473,322 Members | 1,510 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,322 software developers and data experts.

Select Case in a Loop

I want to use select case in a loop as under:
Expand|Select|Wrap|Line Numbers
  1. Dim i As Integer
  2. i = 1
  3. While i < 6
  4.     Select Case Field1
  5.         Case "Title"
  6.             strFld(i) = "([Title] & ': ' & [Subtitle])"
  7.         Case "Author"
  8.             strFld(i) = "([AUTHOR] & ', ' & [SUBAUTHOR])"
  9.         Case "Subject"
  10.             strFld(i) = "Subject"
  11.         Case "Publisher"
  12.             strFld(i) = "Publisher"
  13.         Case "Year of Publication"
  14.             strFld(i) = "Year"
  15.         Case "Call No"
  16.             strFld(i) = "([DDC_NO] & ' ' & [Auth_MARK])"
  17.         Case "Acc No"
  18.             strFld(i) = "ACCNO"
  19.     End Select
  20.     i = i + 1
  21. Wend
  22.  
  23.  
can I use the line no 4 code as:
Select Case Field1, Field2, Field3, Field4, Field5

Note: Field(5) is string variable and strFld(5) is also a string variable
Sep 12 '07 #1
4 5658
MMcCarthy
14,534 Expert Mod 8TB
Try this ...

Expand|Select|Wrap|Line Numbers
  1. Dim i As Integer
  2. i = 1
  3. While i < 6
  4.     Select Case "Field" & i
  5.         Case "Title"
  6.             strFld(i) = "([Title] & ': ' & [Subtitle])"
  7.         Case "Author"
  8.             strFld(i) = "([AUTHOR] & ', ' & [SUBAUTHOR])"
  9.         Case "Subject"
  10.             strFld(i) = "Subject"
  11.         Case "Publisher"
  12.             strFld(i) = "Publisher"
  13.         Case "Year of Publication"
  14.             strFld(i) = "Year"
  15.         Case "Call No"
  16.             strFld(i) = "([DDC_NO] & ' ' & [Auth_MARK])"
  17.         Case "Acc No"
  18.             strFld(i) = "ACCNO"
  19.     End Select
  20.     i = i + 1
  21. Wend
  22.  
  23.  
Sep 12 '07 #2
Dear
Thanks for response.
"Select Case "Field" & i" is treated as:
Select "Field1", "Field2".

But i want to use it as variable, not constant. Field1, Field2... are the names of combo boxes on the form.
Values of these combo boxes may differ in all cases

Ata

Try this ...

Expand|Select|Wrap|Line Numbers
  1. Dim i As Integer
  2. i = 1
  3. While i < 6
  4.     Select Case "Field" & i
  5.         Case "Title"
  6.             strFld(i) = "([Title] & ': ' & [Subtitle])"
  7.         Case "Author"
  8.             strFld(i) = "([AUTHOR] & ', ' & [SUBAUTHOR])"
  9.         Case "Subject"
  10.             strFld(i) = "Subject"
  11.         Case "Publisher"
  12.             strFld(i) = "Publisher"
  13.         Case "Year of Publication"
  14.             strFld(i) = "Year"
  15.         Case "Call No"
  16.             strFld(i) = "([DDC_NO] & ' ' & [Auth_MARK])"
  17.         Case "Acc No"
  18.             strFld(i) = "ACCNO"
  19.     End Select
  20.     i = i + 1
  21. Wend
  22.  
  23.  
Sep 14 '07 #3
MMcCarthy
14,534 Expert Mod 8TB
Dear
Thanks for response.
"Select Case "Field" & i" is treated as:
Select "Field1", "Field2".

But i want to use it as variable, not constant. Field1, Field2... are the names of combo boxes on the form.
Values of these combo boxes may differ in all cases

Ata
Ata

I'm totally confused.

Can you explain logically (not with code) exactly what you are trying to do.
Sep 14 '07 #4
Dear mmccarthy

Thanks for response. Sorry I could not make clear question. But the problem has been solved as under with a slight change:
I hope you may easily understand the following code:

Expand|Select|Wrap|Line Numbers
  1. Dim i As Integer
  2. Dim cb(5) As ComboBox
  3. Set cb(1) = Field1
  4. Set cb(2) = Field2
  5. Set cb(3) = Field3
  6. Set cb(4) = Field4
  7. Set cb(5) = Field5
  8.  
  9. i = 1
  10. While i < 6
  11.     Select Case cb(i)
  12.         Case "Title"
  13.             strFld(i) = "([Title] & ': ' & [Subtitle])"
  14.         Case "Author"
  15.             strFld(i) = "([AUTHOR] & ', ' & [SUBAUTHOR])"
  16.         Case "Subject"
  17.             strFld(i) = "Subject"
  18.         Case "Publisher"
  19.             strFld(i) = "Publisher"
  20.         Case "Year of Publication"
  21.             strFld(i) = "Year"
  22.         Case "Call No"
  23.             strFld(i) = "([DDC_NO] & ' ' & [Auth_MARK])"
  24.         Case "Acc No"
  25.             strFld(i) = "ACCNO"
  26.     End Select
  27.     i = i + 1
  28. Wend
  29.  
  30.  
Ata

I'm totally confused.

Can you explain logically (not with code) exactly what you are trying to do.
Sep 17 '07 #5

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

Similar topics

3
by: Mohammed Mazid | last post by:
Hi folks! Can anyone please help me with this? I am developing a Quiz program but I am stuck with "multiple answers". Basically I need some sort of code that would select multiple answers...
4
by: Ed L. | last post by:
I think I'm seeing table-level lock contention in the following function when I have many different concurrent callers, each with mutually distinct values for $1. Is there a way to reimplement...
6
by: mabond | last post by:
Hi Is it possible to compare a vaule for a select case statement using a wildcard. e.g. somthing like Select case myValue case like "*ing" end select
4
by: Ian Richardson | last post by:
Hi, The function I've put together below is a rough idea to extend a SELECT list, starting from: <body> <form name="bambam"> <select id="fred"> <option value="1">1</option> <option...
22
by: MP | last post by:
vb6,ado,mdb,win2k i pass the sql string to the .Execute method on the open connection to Table_Name(const) db table fwiw (the connection opened via class wrapper:) msConnString = "Data Source="...
16
by: Richard Maher | last post by:
Hi, I have this Applet-hosted Socket connection to my server and in an ONevent/function I am retrieving all these lovely rows from the server and inserting them into the Select-List. (The on...
10
by: Michele Simionato | last post by:
I have always been curious about how people implement mainloops (or, in Twisted terminology, reactors). So I sit down and I wrote the following simple implementation: import itertools class...
1
amitpatel66
by: amitpatel66 | last post by:
Hi, Is PLSQL Anonymous block allowed in CASE WHEN statement when CASE is used in SELECT statement. Check below code which executes but does not return anything: SELECT job, CASE WHEN job =...
4
tjc0ol
by: tjc0ol | last post by:
Hi guys, I'm a newbie in php and I got error in my index.php which is: 1054 - Unknown column 'p.products_id' in 'on clause' select p.products_image, pd.products_name, p.products_id,...
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...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
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)...
1
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...
1
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....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.