Solved

Module needs updating

Posted on 2013-12-09
6
161 Views
Last Modified: 2013-12-10
I have a module that I need to add a field to
The current module creates my starting2 table perfectly
I need to add another Item to the Module  (see attached word doc for the pics)

This part of the module adds the Courses number with a | between each one.  I need it to add one more course to this | list.......    The schoolcode.

 if its schoolcode = 1  I need it to add | "z" + Schoolcode   Hint: (z1)

  if its schoolcode = 2  I need it to add | "z" + Schoolcode   Hint: (z2)
ect.

so.. I assume this new code would go right after the "Loop" ends and adds      | z1  


Do Until rs.EOF
    sInfo1 = sInfo1 & "|" & rs!courses
rs.MoveNext
Loop
    joinThem = sInfo & Mid(sInfo1, 2) & ";"


my result is this
6195;aaaaaab;None;104484;kthg6790f5993;104484;user;30|16|22|11;
and need it to be
6195;aaaaaab;None;104484;kthg6790f5993;104484;user;30|16|22|11|z1;






Full module code incase you need it:

Function joinThem(vID As Long)
Dim rs As DAO.Recordset, sql As String
Dim sInfo As String, sInfo1 As String
sql = "select * from starting1 where LastName=" & vID
Set rs = CurrentDb.OpenRecordset(sql)

sInfo = rs!LastName & ";" & rs!FirstName & ";" & rs!Email & ";" & rs!UserName & ";" & rs!Password & ";" & rs!OfficialCode & ";" & rs!Status & ";"
Do Until rs.EOF
    sInfo1 = sInfo1 & "|" & rs!courses
rs.MoveNext
Loop
    joinThem = sInfo & Mid(sInfo1, 2) & ";"

End Function
pics.docx
0
Comment
Question by:FaithDan
  • 3
  • 3
6 Comments
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
try this

Do Until rs.EOF
    sInfo1 = sInfo1 & "|" & rs!courses
rs.MoveNext
Loop
   sInfo1=sInfo1 & "|" & "z" & schoolcode
0
 
LVL 1

Author Comment

by:FaithDan
Comment Utility
Hello capricorn1

I appreciate you helping me with this

I get an error with this  can you look at it to see what I am missing.

I have attached the debug screen shot.

Thanks again for your help

Below is the code that gives an error

Function joinThem(vID As Long)
Dim rs As DAO.Recordset, sql As String
Dim sInfo As String, sInfo1 As String
sql = "select * from starting1 where LastName=" & vID
Set rs = CurrentDb.OpenRecordset(sql)

sInfo = rs!LastName & ";" & rs!FirstName & ";" & rs!Email & ";" & rs!UserName & ";" & rs!Password & ";" & rs!OfficialCode & ";" & rs!Status & ";"
Do Until rs.EOF
    sInfo1 = sInfo1 & "|" & rs!courses
rs.MoveNext

Loop
    sInfo1 = sInfo1 & "|" & "z" & rs!schoolcode
    joinThem = sInfo & Mid(sInfo1, 2) & ";"

End Function
debug.JPG
error.JPG
0
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
' add this variable and codes

dim schCode

if rs.eof then
    exit sub
    else
    schCode=rs!schoolcode
end if

Do Until rs.EOF
    sInfo1 = sInfo1 & "|" & rs!courses
rs.MoveNext

Loop
    sInfo1 = sInfo1 & "|" & "z" & schCode
 


.
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 1

Author Comment

by:FaithDan
Comment Utility
Hello

I must have placed it wrong within the code.  I get a compile error.  See attached

can you point me in the right direction.

Thanks in advance

FaithDan
compile.JPG
0
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
Comment Utility
oops, sorry

if rs.eof then

    exit function
                 ' exit sub  remove this
    else
    schCode=rs!schoolcode
end if
0
 
LVL 1

Author Closing Comment

by:FaithDan
Comment Utility
Thank you, thank you, thank you so very much.

That worked perfectly.

You are awesome

Have a blessed day

FaithDan
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

743 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now