Hi Folks,
I've got a tough one here that I've been trying to work though every which way I can think of. I know i'm getting closer, because the concept is making more sense now, but I don't think I got the code correct.
I'm trying to take in everyone who is set to graduate in one of our databases, and format it like below (automatically).
DEGREE
Major: Name, City, State; Name, City, State; etc...
DEGREE 2
Major: Name, City, State; etc...
I can easily pump this out where each person is on their own line, but that format is going to cause me or whoever works with this in the end to have to do alot of manually manipulation (which I'm tryign to avoid).
All of this being so, I come with with the below code:
I've been looking up how to do a multidementional array in VBA, but all I could find what tthat ReDim function. Because I want to store 2 values on each index, I figured a 2 dimensional array would work. But I'm getting a type mismatch error. All of the data in the tables is varchar or varchar2, and I think I'm declaring the array correctly..but i'm not sure. Can someone Please help me out with this issue that I'm tryign to resolve. I've done alot of research and the above code is what I've come up with but it doesn't seem to want to work.
ANY IDEAS? HELP!
I've got a tough one here that I've been trying to work though every which way I can think of. I know i'm getting closer, because the concept is making more sense now, but I don't think I got the code correct.
I'm trying to take in everyone who is set to graduate in one of our databases, and format it like below (automatically).
DEGREE
Major: Name, City, State; Name, City, State; etc...
DEGREE 2
Major: Name, City, State; etc...
I can easily pump this out where each person is on their own line, but that format is going to cause me or whoever works with this in the end to have to do alot of manually manipulation (which I'm tryign to avoid).
All of this being so, I come with with the below code:
Code:
Public Function InsertGradData()
DoCmd.SetWarnings False
Dim strSQL1, strSQL2, strSQL3 As String
Dim rs1, rs2 As DAO.Recordset
Dim myArray() As String
Dim r As String
Dim c As String
strSQL1 = "SELECT DISTINCT PeopleGraduating.Degree, PeopleGraduating.Major1 From PeopleGraduating order by Degree"
Set rs1 = CurrentDb.OpenRecordset(strSQL1)
Do Until rs1.EOF
r = RTrim(rs1![Degree])
c = RTrim(rs1![Major1])
ReDim Preserve myArray(r, c)
strSQL2 = "SELECT PeopleGraduating.FullName, PeopleGraduating.City, PeopleGraduating.Degree, PeopleGraduating.Major1, PeopleGraduating.State FROM PeopleGraduating" & _
" Where PeopleGraduating.Degree='" & r & "' and PeopleGraduating.Major1='" & c & "'"
Set rs2 = CurrentDb.OpenRecordset(strSQL2)
strSQL3 = strSQL3 & "; " & rs2![FullName] & ", " & rs2![City] & ", " & rs2![State]
DoCmd.RunSQL "INSERT INTO JAWILLI1_TMP_GRADS (MAJOR,DEGREE,NAMES) VALUES('" & rs1![Major1] & "','" & rs1![Degree] & "','" & EscapeOffRegexChars(strSQL3) & "');"
Loop
End Function
I've been looking up how to do a multidementional array in VBA, but all I could find what tthat ReDim function. Because I want to store 2 values on each index, I figured a 2 dimensional array would work. But I'm getting a type mismatch error. All of the data in the tables is varchar or varchar2, and I think I'm declaring the array correctly..but i'm not sure. Can someone Please help me out with this issue that I'm tryign to resolve. I've done alot of research and the above code is what I've come up with but it doesn't seem to want to work.
ANY IDEAS? HELP!