nuttychick
Registered User.
- Local time
- Today, 17:49
- Joined
- Jan 16, 2004
- Messages
- 84
Hope someone can help - not got loads of experience with VB - It an enherited database running on Access 97, my ws is running on Win2000.
I have the following code on an onclick event of a cmd button. Its basic function is to take the number that has been entered onto the form (always a 4 digit code e.g. 56AA) and check if there are any occurances in the table.stuides like that code (e.g 56AA-1) If there are any occurances then it needs to take the highest numbered one (e.g 56AA-2) and increment the number at the end by 1. e.g.(56AA-3)
At the moment however, if it finds 56AA-1, it makes the new number 56AA-1-2
I've looked by can't identify what actual part of the code is making this change. I've included the majority of the code and I think its is the section I have made red but I don't know!
Free baby bell's my hero!
If InStr(1, Trim([Forms]![frmCloneStudy].[CloneStudyCode]), "-") <> 0 Then
strStudyCode = Left(Trim([Forms]![frmCloneStudy].[CloneStudyCode]),
Len(Trim([Forms]![frmCloneStudy].[CloneStudyCode])) - 2) & "*"
Else
strStudyCode = Trim([Forms]![frmCloneStudy].[CloneStudyCode]) & "*"
End If
'strStudyCode = Mid(Trim([Forms]![frmCloneStudy].[CloneStudyCode]), 1, 4) &
"*"
'Below including Nicki's new where statement to exclude design studies as
per JDB0014 added 18/05/05
MySQL = "SELECT studies.*, studies.Feasibility_code,
business_streams.business_stream_desc, Study_Types.Description,
Study_managers.FullName AS StudyMgr, people.FullName AS AccManager,
people_1.FullName AS ProjManager, people_2.FullName AS Architect,
Study_managers_1.FullName AS ProposalMgr, people_3.FullName AS Sponsor,
people_4.FullName AS DRSContact, BusinessDev.FullName AS BusDev,
BMSDProjMgr.FullName AS BMSDProjMgr "
MySQL = MySQL + "FROM ((Study_managers INNER JOIN ((((((((studies INNER JOIN
business_streams ON studies.business_stream_id =
business_streams.business_stream_id) INNER JOIN Study_Types ON
studies.study_type_id = Study_Types.study_type_id) LEFT JOIN people ON
studies.Acc_Man_id = people.people_id) LEFT JOIN people AS people_1 ON
studies.Proj_Man_id = people_1.people_id) LEFT JOIN people AS people_2 ON
studies.Arch_Man_id = people_2.people_id) LEFT JOIN Study_managers AS
Study_managers_1 ON studies.BDT_Man_id = Study_managers_1.Study_manager_id)
LEFT JOIN people AS people_3 ON studies.Sponsor_id = people_3.people_id)
LEFT JOIN people AS people_4 ON studies.SPD_id = people_4.people_id) ON
Study_managers.Study_manager_id = studies.study_man_id) LEFT JOIN
BusinessDev ON studies.BusinessDevID = BusinessDev.BusDevID) LEFT JOIN
BMSDProjMgr ON studies.BMSDProMgrID = BMSDProjMgr.BMSDProjMgr_id "
MySQL = MySQL + "Where
(((studies.designstudy)=No)AND(studies.Feasibility_code) Like '" &
strStudyCode & "')"
'Mike's orgional where code MySQL = MySQL + "WHERE
((studies.Feasibility_code) Like '" & strStudyCode & "') "
'MySQL = MySQL + "WHERE ((studies.Feasibility_code) Like '" +
Trim(Mid([Forms]![frmCloneStudy].[CloneStudyCode], 1, 4)) & "*" + "') "
MySQL = MySQL + "ORDER BY studies.Feasibility_code DESC; "
Set tempSet = MyDB.OpenRecordset(MySQL, dbOpenSnapshot)
' Get the Cloned Study index number
strStudyCode = tempSet![studies.Feasibility_code]
If CountRecordsInTable(MySQL) = 1 Then
intIndex = 1
Else
intPos = InStr(strStudyCode, "-") + 1
intIndex = Val(Mid(strStudyCode, (InStr(strStudyCode, "-") + 1))) + 1
End If
strIndex = Str(intIndex)
NewStudyCode = UCase(strStudyCode) & "-" & Trim(strIndex)
NewStudyTitle = MySet!study_title & " (" & Trim(strIndex) & ")"
I have the following code on an onclick event of a cmd button. Its basic function is to take the number that has been entered onto the form (always a 4 digit code e.g. 56AA) and check if there are any occurances in the table.stuides like that code (e.g 56AA-1) If there are any occurances then it needs to take the highest numbered one (e.g 56AA-2) and increment the number at the end by 1. e.g.(56AA-3)
At the moment however, if it finds 56AA-1, it makes the new number 56AA-1-2
I've looked by can't identify what actual part of the code is making this change. I've included the majority of the code and I think its is the section I have made red but I don't know!

Free baby bell's my hero!

If InStr(1, Trim([Forms]![frmCloneStudy].[CloneStudyCode]), "-") <> 0 Then
strStudyCode = Left(Trim([Forms]![frmCloneStudy].[CloneStudyCode]),
Len(Trim([Forms]![frmCloneStudy].[CloneStudyCode])) - 2) & "*"
Else
strStudyCode = Trim([Forms]![frmCloneStudy].[CloneStudyCode]) & "*"
End If
'strStudyCode = Mid(Trim([Forms]![frmCloneStudy].[CloneStudyCode]), 1, 4) &
"*"
'Below including Nicki's new where statement to exclude design studies as
per JDB0014 added 18/05/05
MySQL = "SELECT studies.*, studies.Feasibility_code,
business_streams.business_stream_desc, Study_Types.Description,
Study_managers.FullName AS StudyMgr, people.FullName AS AccManager,
people_1.FullName AS ProjManager, people_2.FullName AS Architect,
Study_managers_1.FullName AS ProposalMgr, people_3.FullName AS Sponsor,
people_4.FullName AS DRSContact, BusinessDev.FullName AS BusDev,
BMSDProjMgr.FullName AS BMSDProjMgr "
MySQL = MySQL + "FROM ((Study_managers INNER JOIN ((((((((studies INNER JOIN
business_streams ON studies.business_stream_id =
business_streams.business_stream_id) INNER JOIN Study_Types ON
studies.study_type_id = Study_Types.study_type_id) LEFT JOIN people ON
studies.Acc_Man_id = people.people_id) LEFT JOIN people AS people_1 ON
studies.Proj_Man_id = people_1.people_id) LEFT JOIN people AS people_2 ON
studies.Arch_Man_id = people_2.people_id) LEFT JOIN Study_managers AS
Study_managers_1 ON studies.BDT_Man_id = Study_managers_1.Study_manager_id)
LEFT JOIN people AS people_3 ON studies.Sponsor_id = people_3.people_id)
LEFT JOIN people AS people_4 ON studies.SPD_id = people_4.people_id) ON
Study_managers.Study_manager_id = studies.study_man_id) LEFT JOIN
BusinessDev ON studies.BusinessDevID = BusinessDev.BusDevID) LEFT JOIN
BMSDProjMgr ON studies.BMSDProMgrID = BMSDProjMgr.BMSDProjMgr_id "
MySQL = MySQL + "Where
(((studies.designstudy)=No)AND(studies.Feasibility_code) Like '" &
strStudyCode & "')"
'Mike's orgional where code MySQL = MySQL + "WHERE
((studies.Feasibility_code) Like '" & strStudyCode & "') "
'MySQL = MySQL + "WHERE ((studies.Feasibility_code) Like '" +
Trim(Mid([Forms]![frmCloneStudy].[CloneStudyCode], 1, 4)) & "*" + "') "
MySQL = MySQL + "ORDER BY studies.Feasibility_code DESC; "
Set tempSet = MyDB.OpenRecordset(MySQL, dbOpenSnapshot)
' Get the Cloned Study index number
strStudyCode = tempSet![studies.Feasibility_code]
If CountRecordsInTable(MySQL) = 1 Then
intIndex = 1
Else
intPos = InStr(strStudyCode, "-") + 1
intIndex = Val(Mid(strStudyCode, (InStr(strStudyCode, "-") + 1))) + 1
End If
strIndex = Str(intIndex)
NewStudyCode = UCase(strStudyCode) & "-" & Trim(strIndex)
NewStudyTitle = MySet!study_title & " (" & Trim(strIndex) & ")"