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

Creating a Program Loop in VB

P: 9
Hello,

I am trying to create a loop in an MS Access application that will read in a list of iSeries system names from a file in my Access database, and then submit a command to each of the listed systems.

I have the code working for submitting the commands to one iSeries system at a time, the problem I am encountering is when I try to us a loop to submit the command to a list of systems.

Here is what I have for the command loop, my problem that I have hit, which is probably very rudamentary, is that I can't seem to specify a file within my database correctly.

I keep receiving an error stating "Run-time error '53': File not found

The file definitley exist, and the spelling is correct. Is there some syntax I am missing to specifiy the file in my current database?

*note - iseries is the name of the field which I am trying to read in.

Expand|Select|Wrap|Line Numbers
  1.  
  2. If system_name = "ALL" Then
  3.  
  4.     Open "myfile" For Input As #1
  5.         Do While Not EOF(1)
  6.         system_name = iseries
  7.         YOUR400.Define system_name
  8.  
  9.         Set Command.system = YOUR400
  10.  
  11.         ' Enter USERID and PWD so the users will not be prompted
  12.         Command.system.USERID = USERID
  13.         Command.system.Password = Password
  14.  
  15.         CU = command_run
  16.  
  17.         Command.Run CU
  18.         Loop
  19.     Close #1
  20.  
  21.     MsgBox ("Command '" & command_run & "' has been issued to all systems by '" & USERID & "' ")
  22.  
  23. End If
  24.  
  25.  
Any help is greatly appreciated, and I apologize if this question is very elementary in nature.

Thank you.
May 16 '08 #1
Share this Question
Share on Google+
10 Replies


NeoPa
Expert Mod 15k+
P: 31,186
I'm not really getting the question I'm afraid.

With something like this it's important that you get all your details correct. My understanding starts to go grey and fuzzy in the first paragraph as Access databases don't contain files :S
I am trying to create a loop in an MS Access application that will read in a list of iSeries system names from a file in my Access database, and then submit a command to each of the listed systems.
There are other parts too which don't quite make sense so I couldn't get back on track.

If you have code which does work (for a single item say) then post that explaining what it does.

If you then go on to say where it goes wrong with your attempted loop then it may help someone to help you.
May 16 '08 #2

P: 9
I'm not really getting the question I'm afraid.

With something like this it's important that you get all your details correct. My understanding starts to go grey and fuzzy in the first paragraph as Access databases don't contain files :S

There are other parts too which don't quite make sense so I couldn't get back on track.

If you have code which does work (for a single item say) then post that explaining what it does.

If you then go on to say where it goes wrong with your attempted loop then it may help someone to help you.
Sorry for the confusion, I should have said there is a table in my database that I am trying to read in.

Here is the code that I am using to send a command to a single iSeries server, this code currently works:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command10_Click()
  2.  
  3. Dim systemNames As New cwbx.systemNames
  4. Dim YOUR400 As New cwbx.AS400System
  5. Dim Command As New cwbx.Command
  6. Dim CU As String
  7.  
  8.  
  9.  
  10. YOUR400.Define system_name
  11.  
  12. Set Command.system = YOUR400
  13.  
  14. ' Enter USERID and PWD so the users will not be prompted
  15. Command.system.USERID = USERID
  16. Command.system.Password = Password
  17.  
  18. CU = command_run
  19.  
  20. Command.Run CU
  21.  
  22. MsgBox ("Command '" & command_run & "' has been issued to '" & system_name & "' by '" & USERID & "' ")
  23.  
  24. End Sub
  25.  
The variables are being passed from user input entered on a form, and the process is enacted by clicking a command button.

What I am trying to do is to be able to submit a single command to multiple iSeries servers by reading the list of server names in from a table located in my Access database.

Here is the code I have so far (assuming "myfile" is my table listing the iSeries machines in a column called "iseries":

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command10_Click()
  2.  
  3.  
  4. Dim systemNames As New cwbx.systemNames
  5. Dim YOUR400 As New cwbx.AS400System
  6. Dim Command As New cwbx.Command
  7. Dim CU As String
  8.  
  9. Open "myfile" For Input As #1
  10.         Do While Not EOF(1)
  11.         system_name = iseries
  12.         YOUR400.Define system_name
  13.  
  14.         Set Command.system = YOUR400
  15.  
  16.         ' Enter USERID and PWD so the users will not be prompted
  17.         Command.system.USERID = USERID
  18.         Command.system.Password = Password
  19.  
  20.         CU = command_run
  21.  
  22.         Command.Run CU
  23.         Loop
  24. Close #1
  25.  
  26. MsgBox ("Command '" & command_run & "' has been issued to all systems by '" & USERID & "' ")
  27.  
  28. End Sub
  29.  
Sorry if I am leaving anything out I apologize, I am really new to VB.

Thanks again for all of your insight.
May 16 '08 #3

P: 9
Sorry, one more piece of information:

The form that is submitting the VB script has four fields:

userid (text box)
Password (text box)
system_name (combo box derived from a table (system_options.iseries)
command_run

The entire code uses two If...then statements to determine whether or not the user is trying to submit a command to a single iSeries (AS400) system or all of our iSeries systems (in which case the user would choose ALL instead of a specific system name.)

I removed the If. . .then statements for the sake of separating the code into what works, and what doesn't.

Hope this helps . . . thanks again.
May 16 '08 #4

NeoPa
Expert Mod 15k+
P: 31,186
That's really quite well explained now Cricket.

I will have a look at this over the weekend and see if I can't determine the problem.
May 16 '08 #5

P: 9
That's really quite well explained now Cricket.

I will have a look at this over the weekend and see if I can't determine the problem.

I really appreciate the help, I have been racking my brain and scouring the internet, but all of the examples reference files outside of databases.

On a side note, this site has been a valuable resource while I have been coding for various projects. There is a ton of good info archived here. Thanks to all who contribute, your efforts are helping a lot of people.
May 16 '08 #6

NeoPa
Expert Mod 15k+
P: 31,186
Nice of you to say so. We're trying to build up a useful archive so that it can be used not only as an interactive forum, but also a repository of knowledge for anyone to search through :)
May 16 '08 #7

NeoPa
Expert Mod 15k+
P: 31,186
I didn't manage to get on at all over the weekend so I will fit in a look at this as soon as I can.
May 19 '08 #8

NeoPa
Expert Mod 15k+
P: 31,186
I've had a deeper look now and I'm coming unstuck on your reference to a cwbx object. This is unclear and unreferenced as far as I can see. What and where is the code that defines or declares it?
May 19 '08 #9

P: 9
I've had a deeper look now and I'm coming unstuck on your reference to a cwbx object. This is unclear and unreferenced as far as I can see. What and where is the code that defines or declares it?
I am a little embarrassed to admit I do not know. Most of my coding in VB has been done the "banging my head into walls" method, so some of structure etc. is a bit hazy to me.

I do know that when I have seen connections made to an AS/400 those Dim statements seem to be declared most of the time. I am not sure why they are referred to as cwbx though.

I am going to do some more reading, and will report back with anything further I find.

Thanks again for all of your help.
May 19 '08 #10

NeoPa
Expert Mod 15k+
P: 31,186
I expect it's declared somewhere in your code if not defined (Declaration is where a reference is made to a pre-existing entity (external library or such like) whereas a definition is where it's created within your code).
May 19 '08 #11

Post your reply

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