?
Solved

How do I require a user to enter data in a field?

Posted on 2011-10-03
6
Medium Priority
?
218 Views
Last Modified: 2012-06-27
I have a form that I want to require users to enter data. If the Scheduled Appt field on the form equals yes then require the user to enter the date and time in the App Date/Time field. If the scheduled Appt field equals No then the App Date/Time must be Null. See attached
Scheduled-App.docx
0
Comment
Question by:shieldsco
  • 3
  • 2
6 Comments
 
LVL 12

Expert Comment

by:pdebaets
ID: 36904674
You can use the form BeforeUpdate event procedure to check for these conditions before the data gets updated. Here's an example

if ScheduledAppt  then
    if trim("" & ApptDateTime) = "" then
        msgbox "An Appt Date and Time is required." & vbcrlf & vbcrlf & "Press <ESC> to undo your changes"
        cancel = true
    end if
else
    if trim("" & ApptDateTime) = "" then
    else
        msgbox "An Appt Date and Time is not allowed." & vbcrlf & vbcrlf & "Press <ESC> to undo your changes"
        cancel = true
    end if
end if

Open in new window

0
 
LVL 40

Accepted Solution

by:
als315 earned 2000 total points
ID: 36904747
Test this example (Form1)
DB27377446.mdb
0
 

Author Comment

by:shieldsco
ID: 36904885
I used the following code  with no effect: Private Sub AppDtTime_BeforeUpdate(Cancel As Integer)
If SchAppt Then
    If Trim("" & AppDtTime) = "" Then
        MsgBox "An Appt Date and Time is required." & vbCrLf & vbCrLf & "Press <ESC> to undo your changes"
        Cancel = True
    End If
Else
    If Trim("" & AppDtTime) = "" Then
    Else
        MsgBox "An Appt Date and Time is not allowed." & vbCrLf & vbCrLf & "Press <ESC> to undo your changes"
        Cancel = True
    End If
End If
End Sub
0
Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

 
LVL 12

Expert Comment

by:pdebaets
ID: 36905023
Put the code in the form BeforeUpdate event procedure not the AppDtTime control BeforeUpdate event procedure.
0
 

Author Comment

by:shieldsco
ID: 36905186
works good thanks
0
 

Author Closing Comment

by:shieldsco
ID: 36905195
Very good
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Suggested Courses

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question