Results 1 to 2 of 2

Thread: Data's getting scrammbled?

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2000
    Location
    Cleveland, OH
    Posts
    12
    I'm using the below code to grab a number out of a field called JobNum in a table name Jobs. I also grab a field called Phase which has can either be a number or a letter such as "G". These two are added together to form a string named "strAddItem". Example: JobNum = 0174 and Phase = G, strAddItem = 0174G. This new string is added to a combo list box. The SQL statement looks for records where current = Yes and adds these strings to the combo list box. This works just fine, the problem is the Jet/Access database gets the data in the first field "JobNum" messed up on the first record. I have a value of "0055" as a project number. The value gets changed to that of another project with a phase letter added to it. I don't understand, the code below shows that I am not writting to the database, just querying it. This field once had a relationship with JobNum on another table, this relationship has since been deleted as the fields no longer holds the same data. Would that cause this? Any suggestions would be greatly appreciated, as it is stumping me.

    Private Sub Form_Activate()
    Dim intNumber As Single
    Dim JNCount As String
    Dim intSum As Single
    Dim cboListItem1 As String
    Dim Phase As String
    Dim strAddItem As String
    cboJobs.Clear
    cboJobs.AddItem ""
    intSum = 0
    Set db = OpenDatabase("c:\timesheet\timesheet1.mdb")

    strSQL3 = "Select * FROM [Job Number] WHERE Current = Yes ORDER BY JobNum"
    Set rs3 = db.OpenRecordset(strSQL3, dbOpenDynaset)
    If rs3.RecordCount <> 0 Then
    rs3.MoveLast
    rs3.MoveFirst
    JNCount = rs3.RecordCount
    Else
    JNCount = 0
    End If

    For intNumber = 1 To JNCount
    intSum = intSum + intNumber
    cboListItem1 = rs3.Fields("JobNum")
    Phase = rs3.Fields("Phase")
    If Phase = "N/A" Then
    Phase = ""
    End If
    strAddItem = cboListItem1 & Phase
    cboJobs.AddItem strAddItem
    rs3.MoveNext
    Next intNumber

    End Sub
    Shawn Martin
    Ecopic Corporation
    [email protected] - work
    [email protected] - home

  2. #2
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105
    Does this minor code change make any difference?


    For intNumber = 1 To JNCount
    if rs3.eof then exit sub
    intSum = intSum + intNumber
    If Phase = "N/A" Then
    strAddItem= trim(rs3.Fields("JobNum"))
    else
    strAddItem = trim(rs3.Fields("JobNum")) & trim(rs3.Fields("Phase"))
    End If
    cboJobs.AddItem strAddItem
    rs3.MoveNext
    Next intNumber


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width