Solved

Module needs updating

Posted on 2013-12-09
6
195 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

726 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