Help with code

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
 
K

Klatuu

Have you run the code in debug mode to see where it freezes?

--
Dave Hargis, Microsoft Access MVP


SF said:
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
 
S

SF

How to do that?

SF

Klatuu said:
Have you run the code in debug mode to see where it freezes?

--
Dave Hargis, Microsoft Access MVP


SF said:
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
 
R

Rui

SF,

Open the vba code window, select your sub/function.

Pick a line of code (i.e. Set wsp = DBEngine.Workspaces(0)
and in the grey area just before the code, left click on it. A red
bar/highliter should come appear over the relevant line of code.

Now go back to the form and action the code. Once the execution reaches to
the point highlighted, it should pause. From this point forward you have two
options, either run the code or ,the one that you are looking for, do a step
by step (F8)


by the way
Set wsp = DBEngine.Workspaces(0) ' I couldn't see this declared

Dim qdf1, qdf2 As DAO.QueryDef 'qdf1 might be declared as an object.


Take care
Rui



SF said:
How to do that?

SF

Klatuu said:
Have you run the code in debug mode to see where it freezes?

--
Dave Hargis, Microsoft Access MVP


SF said:
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
 
B

BruceM

I think qdf1 is a variant unless otherwise specified. This is probably what
the OP intended:
Dim qdf1 as DAO.QueryDef, qdf2 As DAO.QueryDef

Rui said:
SF,

Open the vba code window, select your sub/function.

Pick a line of code (i.e. Set wsp = DBEngine.Workspaces(0)
and in the grey area just before the code, left click on it. A red
bar/highliter should come appear over the relevant line of code.

Now go back to the form and action the code. Once the execution reaches to
the point highlighted, it should pause. From this point forward you have
two
options, either run the code or ,the one that you are looking for, do a
step
by step (F8)


by the way
Set wsp = DBEngine.Workspaces(0) ' I couldn't see this declared

Dim qdf1, qdf2 As DAO.QueryDef 'qdf1 might be declared as an
object.


Take care
Rui



SF said:
How to do that?

SF

Klatuu said:
Have you run the code in debug mode to see where it freezes?

--
Dave Hargis, Microsoft Access MVP


:

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
 
A

Amanuel Mus

SF said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

help with Code 1

Top