Referencing a field in a subform (MS Access)
Closed
PNyiam
Posts
21
Registration date
Tuesday July 17, 2018
Status
Member
Last seen
September 5, 2018
-
Updated on Aug 6, 2018 at 10:58 AM
PNyiam Posts 21 Registration date Tuesday July 17, 2018 Status Member Last seen September 5, 2018 - Aug 14, 2018 at 09:45 AM
PNyiam Posts 21 Registration date Tuesday July 17, 2018 Status Member Last seen September 5, 2018 - Aug 14, 2018 at 09:45 AM
Related:
- Referencing a field in a subform (MS Access)
- Ms access download - Download - Databases
- How to access google usa - Guide
- Access and downloading - Facebook Forum
- Attrib access denied ✓ - Hard Drive & SSD Forum
- How to download Facebook data: on mobile and on desktop - Guide
1 response
OK, try this.
Initiate a variable called "mandotoryWorkTime", and set it to the the field you wish:
mandotoryWorkTime = forms!blahblahblah.textfield
Then check for mandotoryWorkTime in your logic statement.
If you wish to what the variable is set up as to troubleshoot programming, place this in place before the logic statement so you can see what the variable is set to:
msgbox(mandotoryWorkTime)
Then after you have verified the variable mandotoryWorkTime is actually what you expected, REM out the msgbox for later troubleshooting if needed.
Try that.
BTW, go ahead and place the HandleExit at the end, so you do not have to publish EXIT sub twice, the handle exit will just flow end, ending the sub.
Initiate a variable called "mandotoryWorkTime", and set it to the the field you wish:
mandotoryWorkTime = forms!blahblahblah.textfield
Then check for mandotoryWorkTime in your logic statement.
If you wish to what the variable is set up as to troubleshoot programming, place this in place before the logic statement so you can see what the variable is set to:
msgbox(mandotoryWorkTime)
Then after you have verified the variable mandotoryWorkTime is actually what you expected, REM out the msgbox for later troubleshooting if needed.
Try that.
BTW, go ahead and place the HandleExit at the end, so you do not have to publish EXIT sub twice, the handle exit will just flow end, ending the sub.
Aug 7, 2018 at 04:39 AM
Form = CompleteTaskForm
Subform = CompleteTaskSubform
Control? = Tasks subform
Table = Tasks
Field = Completed By 1 (Short text data type)
This is what the VBA currently looks like...
Thanks
Aug 7, 2018 at 04:31 PM
The messagebox will display what ever you have loaded into that new variable.
Aug 14, 2018 at 09:45 AM
Private Sub CompleteTaskButton_Click()
On Error GoTo HandleError
If IsNull(Forms.CompleteTaskForm.CompleteTaskQuerySubform.Form.[Completion Date]) = True Then
MsgBox ("Please enter a completion date.")
Else
If IsNull(Forms.CompleteTaskForm.CompleteTaskQuerySubform.Form.[Time Worked (hours)]) = True Then
MsgBox ("Please enter number of hours worked.")
Else
If IsNull(Forms.CompleteTaskForm.CompleteTaskQuerySubform.Form.[Number of Employees Worked]) = True Then
MsgBox ("Please enter number of employees worked.")
Else
If IsNull(Forms.CompleteTaskForm.CompleteTaskQuerySubform.Form.[Completed By 1]) = True Then
MsgBox ("Please enter name or initials of all employees that worked on PM.")
Else
'Save the record
DoCmd.RunCommand acCmdSaveRecord
'Close the form
DoCmd.Close ObjectType:=acForm, ObjectName:=Me.Name, Save:=acSavePrompt
End If
End If
End If
End If
HandleExit:
Exit Sub
HandleError:
MsgBox Err.Description
Resume HandleExit
End Sub
_____________________________________________________________________________________________________________
Private Sub Form_Unload(Cancel As Integer)
If IsNull(Forms.CompleteTaskForm.CompleteTaskQuerySubform.Form.[Completion Date]) = True And IsNull(Forms.CompleteTaskForm.CompleteTaskQuerySubform.Form.[Time Worked (hours)]) = True And IsNull(Forms.CompleteTaskForm.CompleteTaskQuerySubform.Form.[Number of Employees Worked]) = True And IsNull(Forms.CompleteTaskForm.CompleteTaskQuerySubform.Form.[Completed By 1]) = True Then
userresponse = MsgBox("Are you sure you want close?", vbYesNo, "Database Information")
Select Case userresponse
Case 6
Cancel = False
Case 7
Cancel = True
'this line keeps my own form open in my own case
DoCmd.OpenForm "CompleteTaskForm"
End Select
Else
If IsNull(Forms.CompleteTaskForm.CompleteTaskQuerySubform.Form.[Completion Date]) = True Or IsNull(Forms.CompleteTaskForm.CompleteTaskQuerySubform.Form.[Time Worked (hours)]) = True Or IsNull(Forms.CompleteTaskForm.CompleteTaskQuerySubform.Form.[Number of Employees Worked]) = True Or IsNull(Forms.CompleteTaskForm.CompleteTaskQuerySubform.Form.[Completed By 1]) = True Then
MsgBox ("Please either complete Completion Date, Hours Worked, Employees Worked and Completed By, or clear any partial info added to these before closing.")
Cancel = True
DoCmd.OpenForm "CompleteTaskForm"
Else
'Save the record
DoCmd.RunCommand acCmdSaveRecord
Cancel = False
End If
End If
End Sub