Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9177929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:26:20+00:00 2026-06-17T17:26:20+00:00

I have been working on this…but cant working out why it does work I

  • 0

I have been working on this…but cant working out why it does work

I have a dropdown list and when selected it sets a value, which is fine it worked…

but when i want that value to display in another sub routine it wont display ?

please help me ?

and if you like any code should be written a certain way let me know… Im learning from the internet so im not “trained” properly….

<html>
<head>
<title>Break Logs</title>

<HTA:APPLICATION

icon=icon.ico
    singleinstance="yes"
border="thin"
borderStyle="normal"
caption="yes"
maximizeButton="no"
minimizeButton="no"
showInTaskbar="yes"
windowState="normal"
innerBorder="yes"
navigable="no"
scroll="no"
scrollFlat="no"
sysMenu="yes"
>

</head>

<SCRIPT Language="VBScript">

Window.ResizeTo 250, 250

Dim objFSO, wshShell, strUser, Name, LastName, strLogs, strLogFile, strLocation


'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'       GETTING USERS NAME FROM AD  THIS IM NOT USING WHEN AT HOME TESTING...
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
sub asdf

Set wshShell = CreateObject("WScript.Shell")
strUser = wshShell.ExpandEnvironmentStrings("%USERNAME%")
Const ADS_SCOPE_SUBTREE = 2
Set objRootDSE = GetObject("LDAP://RootDSE")
strDomain = objRootDSE.Get("DefaultNamingContext")
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand = CreateObject("ADODB.Command")
Set objCommand.ActiveConnection = objConnection
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.CommandText = "SELECT distinguishedName FROM 'LDAP://" & strDomain & "'                 WHERE objectCategory='User' AND samAccountName = '" & strUser & "'"
Set objRecordSet = objCommand.Execute
If Not objRecordSet.EOF Then
strDN = objRecordSet.Fields("distinguishedName").Value
End If
Set MyUser = GetObject ("LDAP://" & strDN)
Name = myUser.GivenName
LastName = myUser.sn

end sub

Name = "Pavle"
LastName = "Stojanovic"

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'       SETTING TITLEBAR NAME
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
document.title = "Break Logs For " & Name & " " & LastName

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
CONST ForAppending = 8

Set objFSO = CreateObject("Scripting.FileSystemObject")

strLocation = "F:\"
strLogFile = "Late Breaks.txt"

If Not objFSO.FileExists(strLocation & strLogFile) Then
   objFSO.CreateTextFile(strLocation & strLogFile)
End If



Sub Breaks

MorningBreak = (" - Morning Break " & Name & " was late: " & _ 
        HowLate.Value & " Minutes" & vbCrLf & _
    " - Reason: " & Reason.Value & vbCrLF & _
    " - Date Entered: " & Now())


LunchBreak = (" - Lunch Break " & Name & " was late: " & _ 
        HowLate.Value & " Minutes" & vbCrLf & _
    " - Reason: " & Reason.Value & vbCrLF & _
    " - Date Entered: " & Now())

AfternoonBreak = (" - Afternoon Break " & Name & " was late: " & _ 
        HowLate.Value & " Minutes" & vbCrLf & _
    " - Reason: " & Reason.Value & vbCrLF & _
    " - Date Entered: " & Now())

RNA = (" - Ring No Answer Logged By " & Name & vbCrLF & _
   " - On Date: " & Now() & vbCrLF & _ 
   " - Reason: " & Reason.Value)


Other = (" - Date Entered: " & Now() & vbCrLf & _ 
 " - Reason: " & Reason.Value)



If DropDown.Value = 1 Then

' Nothing to be done in this option...

ElseIf DropDown.Value = 2 Then

BreakCode = MorningBreak

ElseIf DropDown.Value = 3 Then

BreakCode = LunchBreak

ElseIf DropDown.Value = 4 Then

BreakCode = AfternoonBreak

ElseIf DropDown.Value = 5 Then

BreakCode = RNA

ElseIf DropDown.Value = 6 Then

BreakCode = Other

Else

MsgBox "Something went wrong, this option shouldn't popup"

End If


' If I do MsgBox to display BreakCode it works here before leaving the sub ?
End Sub



Sub Submit

MsgBox BreakCode ' this doesnt show up and below wont write to text ???

Set strLogs = objFSO.OpenTextFile(strLocation & strLogFile, ForAppending, True)
    strLogs.WriteLine BreakCode & vbCrLf
     strLogs.Close

End Sub



</SCRIPT>
<body bgColor="LightSteelBlue">

<select size="1" name="DropDown" onChange="Breaks">
 <option value="1">Choose Break</option>
  <option value="2">Morning Break</option>
    <option value="3">Lunch Break</option>
     <option value="4">Afternoon Break</option>
      <option value="5">Ring No Answer</option>
       <option value="6">Other</option>
        </select>

<BR>
<BR>

Reason:
<BR>
<input type="text" name="Reason" size="10" style="width:200">

<BR>
<BR>

Minutes Late:
<BR>
<input type="text" name="HowLate" size="10"> 

<BR>
<BR>
<input type="button" value="Submit" onClick="Submit" title="Added Reason for being late.">

</body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T17:26:21+00:00Added an answer on June 17, 2026 at 5:26 pm

    You don’t explicitly define the variable BreakCode anywhere, so what happens is that the script engine automatically defines the variable within the scope where it’s used. Thus you have two variables BreakCode: one in the procedure Breaks, and a different one in the procedure Submit. The latter is never assigned a value, so it remains empty.

    Insert a line

    Dim BreakCode
    

    after this line:

    Dim objFSO, wshShell, strUser, Name, LastName, strLogs, strLogFile, strLocation
    

    and the problem will vanish.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been working on this code but I can't find out what is
I have been working on this for days but I don't get it so
I have been working on this for some time now and just cant quite
I have been working with this for a whole day but i cannot find
I have been working on this problem for a while but still no joy.
I have been working on this program but everytime I attempt to build, I
I have been working on this thing for client broker server system but i
I have been working on this for hours, but I can't get it to
I have been working on this tidy-up-messy-html tags with DOM, but now I realise
I have been working on this code for hours and I cant seem to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.