craigachan
Registered User.
- Local time
- Today, 15:45
- Joined
- Nov 9, 2007
- Messages
- 285
I have a table of medical procedures that I want to merge with Word. I want to know if its possible to declare the variables within a loop. Each letter that will be merged can have 1 to 40 procedures. So basically I want to declare the variables depending on the particular patient letter to be merged, as needed. So I want to know if I can do something this. I've tried the following code but keep getting a compile error. I'm somewhat new to VB and I can't seem to find the rules for this code. Can someone tell me what's wrong with this?
Table Fields: DOS, Desc, Area
Form Fields: DOS, Desc, Area
Code
Dim Me.RC = DCount("DOS", "MyForm")
docmd.openform "MyForm"
For x = 1 to Me.RC
Docmd.openform "MyForm"
Dim varDOS & x as String
Dim varDesc & x as String
Dim varArea & x as String
varDOS & x = Forms!MyForm!DOS
varDesc & x = Forms!MyForm!Desc
varArea & x = Forms!MyForm!Area
docmd.gotorecord , , acnext
Next x
And then I'll merge the document in a similar way. Can I get advise on my compile problem? Thank you.
Table Fields: DOS, Desc, Area
Form Fields: DOS, Desc, Area
Code
Dim Me.RC = DCount("DOS", "MyForm")
docmd.openform "MyForm"
For x = 1 to Me.RC
Docmd.openform "MyForm"
Dim varDOS & x as String
Dim varDesc & x as String
Dim varArea & x as String
varDOS & x = Forms!MyForm!DOS
varDesc & x = Forms!MyForm!Desc
varArea & x = Forms!MyForm!Area
docmd.gotorecord , , acnext
Next x
And then I'll merge the document in a similar way. Can I get advise on my compile problem? Thank you.