Solved

Module needs updating

Posted on 2013-12-09
6
189 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 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39706605
try this

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

Author Comment

by:FaithDan
ID: 39708443
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 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39708473
' 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
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 
LVL 1

Author Comment

by:FaithDan
ID: 39708526
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 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 39708543
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
ID: 39708567
Thank you, thank you, thank you so very much.

That worked perfectly.

You are awesome

Have a blessed day

FaithDan
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
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…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

831 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