Normal Topic Another Simple Question (Read 774 times)
Blair Wettlaufer
Junior Member
Members
**
Offline


No personal text

Posts: 98
Location: Hamilton, ON
Joined: Jun 4th, 2005
Another Simple Question
Oct 19th, 2005 at 5:03am
Print Post Print Post  
Hi all,

I'm setting up a data entry screen that requires certain fields to be filled before allowing the saving of the record -- problem is, it's turning off my ability to save the record even though I've added the data later.  I know I'm missing something simple, can anyone help?

Here is my code, on Form Exit:
[code]
if @userid <>"admin"
{
     if DBCltNo = "" then @MsgBox ("Client Number Required!","","")
     if DBComRate = 0 then @MsgBox ("DB must be assigned ComRate!","","")
     if DBID = "" THEN @MsgBox ("DB Number Required!","","")
     if DBName = "" then @MsgBox ("DB Name Required!","","")
     if DBowes = "" then @MsgBox ("DB Amount Required!","","")
     if DBColl# = "" then @MsgBox ("DB Requires CollID!","","")
     if DBIncurred = "" then
     {      @MsgBox ("DB Ref Date Required - setting to 120 days ago","","")
           DBIncurred = @date-120
     }
     NotifyForm(1)
}

ELSE NotifyForm(0)
[/code]
  

Coesper erat: tunc lubriciles altravia circum&&Urgebant gyros gimbiculosque tophi:&&Moestenui visae borogovides ire meatu:&&Et profugi gemitus exgrabuere rathae
Back to top
 
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: Another Simple Question
Reply #1 - Oct 19th, 2005 at 5:16am
Print Post Print Post  
1.  When you cannot save later, are you getting any message?

2.  Have you tried using IF @ISBLANK(ElementName) vs. ="" ?


3.  Insert WriteLn(...........different message......) in between each of the IF lines to help see which lines are being executed when it locks you out.

  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Another Simple Question
Reply #2 - Oct 19th, 2005 at 12:18pm
Print Post Print Post  
Blair,

Your NotifyForm(1) is only conditional on @UserId not being admin.  You need to change your logic so that it also checks the state of the data. Otherwise, only admin will ever be able to save.

Also, the stack of MsgBoxes that the user must dismiss one by one may become quite annoying. Try something like this (untested):

Code
Select All
var vOKToSave as Int
var vMsg as String

	// Assume we are OK
	vOKToSave = 1
	vMsg = ""
	NotifyForm(0)

	// Only non-admin users are subject to validation
	If @UserID <> "admin"
	{
		// Assemble a message containing all the errors
		// Clear the OK flag if any validation fails
		if DBCltNo = ""
		{
			vMsg = vMsg + @NewLine() + "Client Number Required!"
			vOKToSave = 0
		}
		if DBComRate = 0
		{
			vMsg = vMsg + @NewLine() + "DB must be assigned ComRate!"
			vOKToSave = 0
		}
		if DBID = ""
		{
			vMsg = vMsg + @NewLine() + "DB Number Required!"
			vOKToSave = 0
		}
		if DBName = ""
		{
			vMsg = vMsg + @NewLine() + "DB Name Required!"
			vOKToSave = 0
		}
		if DBowes = ""
		{
			vMsg = vMsg + @NewLine() + "DB Amount Required!"
			vOKToSave = 0
		}
		if DBColl# = ""
		{
			vMsg = vMsg + @NewLine() + "DB Requires CollID!"
			vOKToSave = 0
		}
		if DBIncurred = ""
		{
			vMsg = vMsg + @NewLine() + "DB Ref Date Required - setting to 120 days ago"
			DBIncurred = @date-120
			vOKToSave = 0
		}

		// If any validation failed, prevent saving and show failures
		If vOKTOSave = 0
		{
			NotifyForm(1)
			@MsgBox(vMsg, "", "")
		}
	} 

  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Blair Wettlaufer
Junior Member
Members
**
Offline


No personal text

Posts: 98
Location: Hamilton, ON
Joined: Jun 4th, 2005
Re: Another Simple Question
Reply #3 - Oct 19th, 2005 at 5:54pm
Print Post Print Post  
Thanks!  That seems to work ...
  

Coesper erat: tunc lubriciles altravia circum&&Urgebant gyros gimbiculosque tophi:&&Moestenui visae borogovides ire meatu:&&Et profugi gemitus exgrabuere rathae
Back to top
 
IP Logged