?
Solved

use a variable in a with statemen

Posted on 2007-08-02
8
Medium Priority
?
151 Views
Last Modified: 2010-04-30
i need to use a variable in a with statement I have the code below. but it does not work any idea of how to achieve this.

--------------------------------------------------------------

Dim whatrecses As String

Select Case WhattoProc

   Case "Dis"
      whatrecset = "with DeCopyservice1.rscmdtoDis"
   Case "Bill"
     whatrecset = "with DeCopyservice1.rscmdtobebilled"
   Case "Uro"
     whatrecset = "with DeCopyservice1.rscmduro"
End Select

 With whatrecset

-----------------------------------------------------------------------------
0
Comment
Question by:BPWALKIN
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 19617731
you can try this:

dim whatrecset
Select Case WhattoProc

   Case "Dis"
      set whatrecset =callbyname("DeCopyservice1","rscmdtoDis")
   Case "Bill"
     set whatrecset = callbyname("DeCopyservice1","rscmdtobebilled")
   Case "Uro"
     set whatrecset = callbyname("DeCopyservice1","rscmduro")
End Select

with whatrecset
  ...
end with
 
0
 
LVL 33

Expert Comment

by:hongjun
ID: 19617750
Try this

with DeCopyservice1
      Select Case WhattoProc
         Case "Dis"
            Set whatrecset = .rscmdtoDis
         Case "Bill"
           Set whatrecset = .rscmdtobebilled
         Case "Uro"
           Set whatrecset = .rscmduro
      End Select
End With


hongjun
0
 

Author Comment

by:BPWALKIN
ID: 19617811
hogiun

   it looks like it might work but the with statement needs to be

   with Decopyservice.the correct record set

how do I achieve that
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 33

Expert Comment

by:hongjun
ID: 19617844
angelIII's looks like it's what you need.
I don't really understand your problem.

hongjun
0
 

Author Comment

by:BPWALKIN
ID: 19617866
angell i am getting a type mismatch on yours when It hits the Decopyservice
0
 
LVL 38

Accepted Solution

by:
PaulHews earned 2000 total points
ID: 19618019
Dim whatrecses As Recordset

Select Case WhattoProc

   Case "Dis"
      Set whatrecset = DeCopyservice1.rscmdtoDis
   Case "Bill"
     Set whatrecset = DeCopyservice1.rscmdtobebilled
   Case "Uro"
     Set whatrecset = DeCopyservice1.rscmduro
End Select

With whatrecset ...
0
 
LVL 38

Expert Comment

by:PaulHews
ID: 19618095
That should be seen not as new solution, but in addition to angel's and hongjun's...
0
 

Author Comment

by:BPWALKIN
ID: 20176149
sorry for the dlay in posting. I had switched jobs and was away form the account for a while
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question