Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Mandatory field and pop up message

 
Logged in as: Guest
arrSession:exec spGetSession 2,7,49580
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [General Forum] >> Other Programming/Scripting Languages >> Mandatory field and pop up message
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 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
 
 
Post #: 1
 
 RE: Mandatory field and pop up message - 7/17/2007 1:10:40 AM   
  dm_4ever


Posts: 2174
Score: 32
Joined: 6/29/2006
From: Orange County, California
Status: offline
This is VBA and not VBScript, but perhaps someone here may be able to provide some guidance for you.

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to peelola)
 
 
Post #: 2
 
 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

(in reply to peelola)
 
 
Post #: 3
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [General Forum] >> Other Programming/Scripting Languages >> Mandatory field and pop up message Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts