Solved

Module needs updating

Posted on 2013-12-09
6
173 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
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 119

Expert Comment

by:Rey Obrero
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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
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 119

Accepted Solution

by:
Rey Obrero 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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
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…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

895 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

20 Experts available now in Live!

Get 1:1 Help Now