S
SF
Hi,
The following code give me a hard time to find the problem. The form is just
freeze when the code run. What is wrong with this code?
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim rstMeeting As DAO.Recordset
Dim rstAttendance As DAO.Recordset
Dim qdf1, qdf2 As DAO.QueryDef
Dim varItem As Long
Dim MsgStg As String
If IsNull(Me.Me_MOFRef_ID) Then
MsgBox "You must provide the 'Received Reference Number' from the
dropdown list", vbOKOnly + vbInformation
Me.Me_MOFRef_ID.SetFocus
Exit Sub
ElseIf IsNull(Me.cmbReceiveType) Then
MsgBox "You must select Type from the dropdown list", vbOKOnly +
vbInformation
Me.cmbReceiveType.SetFocus
Exit Sub
End If
Set wsp = DBEngine.Workspaces(0)
Set dbs = CurrentDb
wsp.BeginTrans
DoCmd.Hourglass True
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tblMOFReceiveDetail", dbOpenDynaset,
dbSeeChanges)
With rst
.AddNew
''![ME_ReceiveID] = Me.ME_ReceiveID
![Me_MOFRef_ID] = Me.Me_MOFRef_ID
![Me_OrgID] = Me.Me_OrgID
![Me_Date] = Me.Me_Date
![Me_MeetingType] = Me.Me_MeetingType
![Me_ProvinceID] = Me.Me_CommuneID.Column(3)
![Me_DistrictID] = Me.Me_CommuneID.Column(2)
![Me_CommuneID] = Me.Me_CommuneID
![DateUpdate] = Now()
![Owner] = CurrentUser()
.Update
End With
rst.Close
DoCmd.Hourglass False
''DoCmd.Close
Select Case Me.cmbReceiveType
Case Is = "MOF"
Set rstMeeting = dbs.OpenRecordset("tblMeetings", dbOpenDynaset,
dbSeeChanges)
With rstMeeting
.AddNew
![Me_Date] = Me.Me_Date
![Me_OrgID] = Me.Me_OrgID
![Me_ContactID] = Me.Me_ContactID
![Me_ProvinceID] = Me.Me_CommuneID.Column(3) 'Me.cmbProvinceID
' Me.Target_Communes.Column(5) '' Me.Me_ProvinceID
![Me_DistrictID] = Me.Me_CommuneID.Column(2) 'Me.cmdDistrictID
' Me.Target_Communes.Column(4) 'Me.Me_DistrictID
![Me_CommuneID] = Me.Me_CommuneID ' Me.Target_Communes
''Me.Me_CommuneID
![Me_MeetingType] = Me.Me_MeetingType
![Me_MeetingTypeReason] = Me.Me_MeetingTypeReason
![ME_ReceiveID] = Me.Me_MOFRef_ID
![DateUpdate] = Now()
![Owner] = CurrentUser()
![DateCreate] = Now()
.Update
.Bookmark = .LastModified
ZZNAV_CURRENTID = ![Me_MeetingID]
End With
rstMeeting.Close
Call AddMOFQuestion(ZZNAV_CURRENTID)
MsgStg = "Your MOF ID is: " & ZZNAV_CURRENTID & " "
Case Else
Set rstAttendance = dbs.OpenRecordset("tblTrainingAttendance",
dbOpenDynaset, dbSeeChanges)
With rstAttendance
.AddNew
![Al_OrgID] = Me.Me_OrgID
![Al_CommuneID] = Me.Me_CommuneID
![Al_TrainingSubjectID] = Me.Al_TrainingSubjectID
![Al_TrainDate] = Me.Me_Date '' Me.Al_TrainDate
''![Al_Remarks] = Me.Al_Remarks
![Al_recordeBy] = CurrentUser() '' Me.Al_recordeBy
![Al_DateRecorded] = Now() '' Me.Al_DateRecorded
![DateUpdate] = Now()
![Owner] = CurrentUser()
![Station] = fOSMachineName()
![ReceiveLogID] = Me_MOFRef_ID
![Al_VillageID] = Me.Me_VillageID
.Update
.Bookmark = .LastModified
ZZNAV_CURRENTID = ![AlID]
End With
rstAttendance.Close
MsgStg = "Your Attendance List ID is: " & ZZNAV_CURRENTID & " "
End Select
wsp.CommitTrans
DoCmd.Hourglass False
Me.List21.Requery
MsgBox MsgStg, vbOKOnly + vbInformation '' "Your ID is: " & ZZNAV_CURRENTID,
vbOKOnly
The following code give me a hard time to find the problem. The form is just
freeze when the code run. What is wrong with this code?
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim rstMeeting As DAO.Recordset
Dim rstAttendance As DAO.Recordset
Dim qdf1, qdf2 As DAO.QueryDef
Dim varItem As Long
Dim MsgStg As String
If IsNull(Me.Me_MOFRef_ID) Then
MsgBox "You must provide the 'Received Reference Number' from the
dropdown list", vbOKOnly + vbInformation
Me.Me_MOFRef_ID.SetFocus
Exit Sub
ElseIf IsNull(Me.cmbReceiveType) Then
MsgBox "You must select Type from the dropdown list", vbOKOnly +
vbInformation
Me.cmbReceiveType.SetFocus
Exit Sub
End If
Set wsp = DBEngine.Workspaces(0)
Set dbs = CurrentDb
wsp.BeginTrans
DoCmd.Hourglass True
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tblMOFReceiveDetail", dbOpenDynaset,
dbSeeChanges)
With rst
.AddNew
''![ME_ReceiveID] = Me.ME_ReceiveID
![Me_MOFRef_ID] = Me.Me_MOFRef_ID
![Me_OrgID] = Me.Me_OrgID
![Me_Date] = Me.Me_Date
![Me_MeetingType] = Me.Me_MeetingType
![Me_ProvinceID] = Me.Me_CommuneID.Column(3)
![Me_DistrictID] = Me.Me_CommuneID.Column(2)
![Me_CommuneID] = Me.Me_CommuneID
![DateUpdate] = Now()
![Owner] = CurrentUser()
.Update
End With
rst.Close
DoCmd.Hourglass False
''DoCmd.Close
Select Case Me.cmbReceiveType
Case Is = "MOF"
Set rstMeeting = dbs.OpenRecordset("tblMeetings", dbOpenDynaset,
dbSeeChanges)
With rstMeeting
.AddNew
![Me_Date] = Me.Me_Date
![Me_OrgID] = Me.Me_OrgID
![Me_ContactID] = Me.Me_ContactID
![Me_ProvinceID] = Me.Me_CommuneID.Column(3) 'Me.cmbProvinceID
' Me.Target_Communes.Column(5) '' Me.Me_ProvinceID
![Me_DistrictID] = Me.Me_CommuneID.Column(2) 'Me.cmdDistrictID
' Me.Target_Communes.Column(4) 'Me.Me_DistrictID
![Me_CommuneID] = Me.Me_CommuneID ' Me.Target_Communes
''Me.Me_CommuneID
![Me_MeetingType] = Me.Me_MeetingType
![Me_MeetingTypeReason] = Me.Me_MeetingTypeReason
![ME_ReceiveID] = Me.Me_MOFRef_ID
![DateUpdate] = Now()
![Owner] = CurrentUser()
![DateCreate] = Now()
.Update
.Bookmark = .LastModified
ZZNAV_CURRENTID = ![Me_MeetingID]
End With
rstMeeting.Close
Call AddMOFQuestion(ZZNAV_CURRENTID)
MsgStg = "Your MOF ID is: " & ZZNAV_CURRENTID & " "
Case Else
Set rstAttendance = dbs.OpenRecordset("tblTrainingAttendance",
dbOpenDynaset, dbSeeChanges)
With rstAttendance
.AddNew
![Al_OrgID] = Me.Me_OrgID
![Al_CommuneID] = Me.Me_CommuneID
![Al_TrainingSubjectID] = Me.Al_TrainingSubjectID
![Al_TrainDate] = Me.Me_Date '' Me.Al_TrainDate
''![Al_Remarks] = Me.Al_Remarks
![Al_recordeBy] = CurrentUser() '' Me.Al_recordeBy
![Al_DateRecorded] = Now() '' Me.Al_DateRecorded
![DateUpdate] = Now()
![Owner] = CurrentUser()
![Station] = fOSMachineName()
![ReceiveLogID] = Me_MOFRef_ID
![Al_VillageID] = Me.Me_VillageID
.Update
.Bookmark = .LastModified
ZZNAV_CURRENTID = ![AlID]
End With
rstAttendance.Close
MsgStg = "Your Attendance List ID is: " & ZZNAV_CURRENTID & " "
End Select
wsp.CommitTrans
DoCmd.Hourglass False
Me.List21.Requery
MsgBox MsgStg, vbOKOnly + vbInformation '' "Your ID is: " & ZZNAV_CURRENTID,
vbOKOnly