First time for Requirement fields and field grayed out and filled

undefeatedskillz26

Registered User.
Local time
Today, 17:20
Joined
Nov 26, 2014
Messages
51
This is my first attempt at coding in visual basic.

I have a few companies that have their own front end database in Access. Most of the databases will communicate to one backend database which is in Access for now.

Here is what I would like to do:

For each database I have about 4 or 5 forms that are exactly the same. For instance I have a form where the end user will input his customer’s first name, last name, and a drop down list of which company its coming from.
The end user should not have to fill out the form for which company he works for. This drop down list or even text box should be grayed out and filled in already .

Now when the user submits the form into the back end of the database's table I should know who it is coming from. I know everyone should have an employee id and I should track it this way, but there are some parts of the forms like feedback I want to remain anonymous.

How can I make the dropdown list or text box filled in and grayed out. The Name of the dropdown list is CompanyName and there are 4 choices.

This is my first attempt on making the fields required, I know it maybe wrong but would like to try. I copied the code to what I think looks right:

Private Sub Command50_Click()

If IsNull([FirstName]) Then
MsgBox "Please input First Name"
DoCmd.CancelEvent

Exit Sub

ElseIf IsNull([LastName]) Then
MsgBox "Please input Last Name"
DoCmd.CancelEvent

Exit Sub

End If
 
Ok can anyone let me know how to make a field a requirement? The end user has to enter required info before hitting the submit button?

This is what I have but there is errors. :(

Private Sub Command50_Click()

If IsNull([FirstName]) Then

MsgBox "Please input First Name"
DoCmd.CancelEvent

Exit Sub

ElseIf IsNull([LastName]) Then
MsgBox "Please input Last Name"
DoCmd.CancelEvent

Exit Sub

End If
 
You don't say what the errors are. You can make a field required in the table, use the before update event of the form:

http://www.baldyweb.com/BeforeUpdate.htm

Your button code looks okay offhand, but you don't need the CancelEvent, just don't execute the save code unless the tests are met.
 

Users who are viewing this thread

Back
Top Bottom