Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
New View Record creates two records
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00569681
Message ID:
00569764
Views:
42
Hi,

Try doing the append blank on the 'meetings' table then do a requery of the 'schcase' view before doing the replace. The Save will then do a tableupdate() of the 'meetings' table and a requery of the 'schcase' view.

HTH,
Arriyel

>I have a view on a table. I'm trying to use this view on a form to Add/Edit a scheduled case. I pass the form some variables and then in the INIT I run the following:
>
>
>IF !tlEdit
>	lcDate=DTOC(calDate(tnStartDate))
>	lcTime=formattime(tnStartTime)
>	thisform.statedatetime=CTOT(lcDate+[ ]+lcTime)
>	lnNextMeetID=gnnext("MEETINGS")
>	gnMeetID=lnNextMeetID
>	=REQUERY("MeetingProcedures")
>	SELECT schcase
>	=REQUERY("schcase")
>	APPEND blank
>	replace meetingnumber_a with lnNextMeetID
>	replace meetingnumber_b with lnNextMeetID
>	replace dept WITH gcViewDept
>	replace roomname WITH tcRoomName
>	replace schcase.begintime WITH rnd_dt15(thisform.statedatetime,900)
>	replace schcase.endtime WITH begintime+1800
>eLSE
>	thisform.backcolor=RGB(255,255,224)
>	gnMeetID=tiMeetID
>	SELECT schcase
>	=REQUERY('schcase')
>	=REQUERY('meetingprocedures')
>endif
>
>
>The problem I have is when tlEdit=.t., I requery("schcase") this returns 0 records since it is a new case. Then I do the Append Blank and the replaces. After that if I do a browse on the view (schcase) it shows my one record. If I then do a browse on the table primary table the view uses (Meetings), it shows a blank record and the one I've done the replaces on. If I don't do the Append Blank, the form controls are disabled (the control source for the form fields are schdata.fieldname) since there is no record. But once I hit the save button, my tableupdates save both records in the meeting table:
>
>
>=TABLEUPDATE(.t.,.t.,'schcase')       <== My View used to edit/add
>=TABLEUPDATE(.t.,.t.,'meetings')      <== Primary Table used in View
>=TABLEUPDATE(.t.,.t.,'schedemo')      <== Secondary table linked in view
>
>
>This is a new approach to me since I normally just created variables to store the data with a scatter. But with buffering and stuff, this seemed like a good approach. Every works great, except that I get two records in meetings. Any help appreciated. VFP6/7
>
>Kirk
Speak using soft and sweet words in case you have to eat them later.
Previous
Reply
Map
View

Click here to load this message in the networking platform