|
-
Aug 10th, 2000, 12:07 PM
#1
Thread Starter
New Member
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|