Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

New data in a read only field

Status
Not open for further replies.

JTimothy

Technical User
Apr 19, 2000
10
0
0
US
Is there a way that you can add a new record using a form that has the first two fields read only? For example I have a form that I have "Last name" and "First Name" as the first two fields in the database,they are keyed, and they are read only in the form. I cannot add new records using the form. Is there a code or a way around this? My ultimate goal is to creat a form that I can add new records and be able to update certain fields but NOT be able to change other certain fields unless I am an "administrator".

Here is the problem:
Some of my staff when looking up a person forgets to pull down the "lookup menu" first before typing in the last name. They in essence type over the last name field for the first person in the database many times this results in the first record being changed. for example: adams, joe becomes smith, joe or o'conner, joe and we have to figure out the change and correct it.
 
Jtimothy,

Why not have two buttons on your form one to find existing customers and another to add a new customer. for instance the coding on my button for adding a new customer is along the lines:

method pushButton(var eventInfo Event)
var
n Number
endVar

tc.attach(Customer_No)
Customer_No.edit()
Customer_No.insertRecord()

DoDefault

Customer_No = tc.cMax("Customer_No") + 1

ExamDate = today()

Customer_No.postRecord()
Name.moveTo()
endmethod

and on the find button:

method pushButton(var eventInfo Event)
menuAction(MenuRecordLocateValue)
endmethod

These are very simplistic but work. there is also a very good thread some time back in which a button was coded for looking up a record on first and last name fields, with the coding looking like this:

method pushButton(var eventInfo Event)
var
f Form
anyRetVal AnyType
myAr Array[] String
qLname,qFname String
tc tCursor
endVar

if NOT f.open("persrch.fsl")
then msgStop("Error opening Form", "Please make sure the form exists and try again.")
return
endIf

anyRetVal = f.wait()

if anyRetVal.dataType() = "Logical"
then msgInfo("Cancelled","User closed search form improperly")
return
endif

anyRetval.breakApart(myAr)
qLname = myAr[1]
qFname = myAr[2]
tc.open("Cust1")

if qFname = "XXX" then
if not tc.locate("Last Name", qLname)
then msgInfo("Not Found",qLname+" not found.")
tc.close()
return
else Last_NameFld.resync(tc)
tc.close()
endif

ELSE

if not tc.locate("Last Name", qLname, "First Name", qFname)
then msgInfo("Not Found",qFname+" "+qLname+" not found.")
tc.close()
return
else Last_NameFld.resync(tc)
tc.close()
endif
endif
endMethod

Lots of assistance was given on this particular topic from the great chaps & chapesess on this forum.

If you want you can always e mail me a copy of your form and I will have a look at it, maybe we can swap ideas.

Hope his is of help.

Lewy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top