[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Module needs updating

Posted on 2013-12-09
6
Medium Priority
?
209 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
Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

 
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 2000 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

649 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