Login | |
|
 |
Mandatory field and pop up message - 7/16/2007 1:18:43 PM
|
|
 |
|
| |
peelola
Posts: 1
Score: 0
Joined: 7/16/2007
Status: offline
|
Hi I have been asked to look at an access database and try and add a mandatory field. I though it would be easy as having done ASP things in the distance past and played around with Access databases it thought it would be an easy job, but I can't for the life of me find out how to make it work. There are 4 fields and the company field needs to be mandatory so that when someone clicks the visitor pass print button a message pops up if they haven't entered anything in the company field. I have no idea where to start with this and can't find anyone to help, finding knowledgeable people here in NZ for this stuff isn't easy! Anyway details below. Option Compare Database Private Sub cmdPrintPass_Click() Dim Name As String Dim Company As String Dim RegNo As String Dim HostName As String Dim InDate As String Dim InTime As String Name = IIf(IsNull(txtName), " ", txtName) Company = IIf(IsNull(txtCompany), " ", txtCompany) RegNo = IIf(IsNull(txtRegNo), " ", txtRegNo) HostName = IIf(IsNull(txtHostName), " ", txtHostName) InDate = CDate(Date) InTime = CDate(Time) lFnInsertIntoVisitor Name, Company, RegNo, HostName, InDate, InTime DoCmd.OpenReport "rptVisitorPass", acViewNormal 'Rhonda asked to take off the second page of the label 16/07/2004 'DoCmd.OpenReport "rptVisitorPolicy", acViewNormal lFnNextCustomer End Sub Private Sub lFnNextCustomer() DoCmd.Close acForm, "frmSignIn" DoCmd.OpenForm "frmSignIn" End Sub Private Sub lFnInsertIntoVisitor(Name As String, Company As String, RegNo As String, HostName As String, InDate As String, InTime As String) Dim MyDb As Database Dim MyRec As Object Set MyDb = CurrentDb Set MyRec = MyDb.OpenRecordset("Visitor") With MyRec .AddNew .Fields("Name") = Name .Fields("Company") = Company .Fields("CarRegNo") = RegNo .Fields("HostName") = HostName .Fields("InDate") = InDate .Fields("InTime") = InTime .Update .MoveLast txtVisitorNO = .Fields(0).Value End With End Sub Private Sub cmdSignInClose_Click() DoCmd.Close acForm, "frmSignIn" End Sub Private Sub Form_Open(Cancel As Integer) DoCmd.Maximize End Sub
|
|
| |
|
|
|
 |
RE: Mandatory field and pop up message - 7/19/2007 11:40:05 AM
|
|
 |
|
| |
ehvbs
Posts: 2012
Score: 48
Joined: 6/22/2005
From: Germany
Status: offline
|
Hi peelola, quick, dirty, and not tested: Company = IIf(IsNull(txtCompany), " ", txtCompany) RegNo = IIf(IsNull(txtRegNo), " ", txtRegNo) HostName = IIf(IsNull(txtHostName), " ", txtHostName) InDate = CDate(Date) InTime = CDate(Time) If "" = Trim( Company ) Then ' nix in txtCompany MsgBox "Please enter company." Exit Sub End If lFnInsertIntoVisitor Name, Company, RegNo, HostName, InDate, InTime Good luck! ehvbs
|
|
| |
|
|
|
|
|