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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Browse - Browse does not allow inserts after using filter & ResetSort

Status
Not open for further replies.

emaduddeen

Programmer
Mar 22, 2007
184
US
Hi.

I have a browse on an abc form procedure. This form is the first window the user sees when the application starts. The procedure initially calls a browse to allow the selection of a custumer when the form procedure will use. After the customer is selected the application calls the update procedure in non-stop batch add mode to fill in the browse which is on a child table. On the form is a button to allow further selections of a new customer to complete transactions.

Here is the problem. Selecting a customer and adding several child table rows works fine. The problem starts when I use a filter and ResetSort to clear the browse prior to selecting the new customer. The update procedur get called after selecting the customer and when I click "Ok" to save the transaction detail, nothing shows up in the browse.

I am sure I am not using the correct code. Can you help me correct the code? Thank you so much for the time everyone has been giving me.

Truly,
Emad

In the "Init" embed:
Code:
! Tell the form to go into insert mode & fill dropdowns.
!-------------------------------------------------------
GlobalRequest = InsertRecord

Access:TransactionHeader.PrimeAutoInc

! Fill Payment Type queue for the Payment Type dropdown.
!-------------------------------------------------------
Clear (PaymentTypeQue)

LOC:SortNumberCounter = 1

Set (PaymentTypes, PAY:KeyPaymentType)

! Stay here until the end of file.
!---------------------------------
Loop Until Access:PaymentTypes.Next()
  PaymentTypeQue:PaymentType = PAY:PaymentType
  PaymentTypeQue:SortNumber =  LOC:SortNumberCounter

  Add (PaymentTypeQue)

  LOC:SortNumberCounter = LOC:SortNumberCounter + 1
End

In the "open window" embed:
Code:
! Get the preferences values.
!----------------------------
PRE:Id = 1
Get (Preferences, PRE:PreferencesKey)

! Set defaults.
!--------------
TranHed:TransactionType = 'Sale'
TranHed:PaymentType = ''

Display()

! Display the screen to select a customer.
!-----------------------------------------
GlobalRequest = SelectRecord

! Disable these.
!---------------
Toolbar11.SetEnabled (ID11_btnInsert, False)
Toolbar11.SetEnabled (ID11_btnChange, False)
Toolbar11.SetEnabled (ID11_btnDelete, False)

SelectCustomer

If GlobalResponse = RequestCompleted |
Then
   ! Populate Point of Sale screen header information.
   !--------------------------------------------------
   TranHed:DateOfSale = today()
   TranHed:TimeOfSale = clock()

   LOC:CustomerName = Clip (CUS:Forename) & ' ' & CUS:Surname
   LOC:CityStatePostcode = Clip (CUS:City) & ', ' & Clip (CUS:StateProvence) & ' ' & CUS:Postcode
   LOC:AlternateCityStatePostcode = Clip (CUS:AlternateCity) & ', ' & Clip (CUS:AlternateStateProvence) & ' ' & CUS:AlternatePostcode
   TranHed:CustNumber = CUS:CustNumber
   GLO:CustNumber = CUS:CustNumber

   If CUS:AlternateAddressLine1 <> '' |
   Then
      LOC:ShippingAddressLabel = ' Shipping Address '
   Else
      LOC:ShippingAddressLabel = ''
   End

   ! Enable these.
   !---------------
   Toolbar11.SetEnabled (ID11_btnInsert, True)

   ?Insert {PROP:Disable} = False

   ! Click on the Insert button.
   !----------------------------
   Post (EVENT:Accepted, ?Insert)
Else
   ! The user canceled the search customer window.
   !----------------------------------------------
   If TranHed:CustNumber = '' |
   Then
     ! Make sure the user can't do anything until a customer is chosen.
     !-----------------------------------------------------------------
     ?SalesItemsList {PROP:Disable} = True
     ?TranHed:PaymentType {PROP:Disable} = True
     ?TranHed:PaymentAmount {PROP:Disable} = True
     ?CancelOrder {PROP:Disable} = True
     ?SaveAndPrint {PROP:Disable} = True
   End
End

Display()

In the button that saves the transaction and transaction details. This is in the "Acepted" embed:
Code:
Message ('Your sales receipt has been saved.', 'Sales Receipt')

Erase (?LOC:CustomerName, ?TranHed:PaymentAmount)

! Erase the data in the browse.
!------------------------------
SalesItemsList.SetFilter('1=0','9Z')
SalesItemsList.ResetSort(True)

Access:TransactionHeader.PrimeAutoInc

! Reset browse so it will allow inserts.
!---------------------------------------
SalesItemsList.SetFilter('')
SalesItemsList.ResetSort(True)

In the button that allows the user to select a new customer. This is in the "Acepted" embed:
Code:
Display (?TranHed:TransactionNumber)

! Redisplay the browse.
!----------------------
SalesItemsList.ResetSort(True)
DISPLAY(?SalesItemsList)

! Display the screen to select a customer.
!-----------------------------------------
GlobalRequest = SelectRecord

! Disable these.
!---------------
Toolbar11.SetEnabled (ID11_btnInsert, False)
Toolbar11.SetEnabled (ID11_btnChange, False)
Toolbar11.SetEnabled (ID11_btnDelete, False)

TranHed:TransactionType = 'Sale'
TranHed:PaymentType = 'MC / Visa'

SelectCustomer

If GlobalResponse = RequestCompleted |
Then
   ! Populate Point of Sale screen header information.
   !--------------------------------------------------
   TranHed:DateOfSale = today()
   TranHed:TimeOfSale = clock()

   LOC:CustomerName = Clip (CUS:Forename) & ' ' & CUS:Surname
   LOC:CityStatePostcode = Clip (CUS:City) & ', ' & Clip (CUS:StateProvence) & ' ' & CUS:Postcode
   LOC:AlternateCityStatePostcode = Clip (CUS:AlternateCity) & ', ' & Clip (CUS:AlternateStateProvence) & ' ' & CUS:AlternatePostcode
   TranHed:CustNumber = CUS:CustNumber
   GLO:CustNumber = CUS:CustNumber

   If CUS:AlternateAddressLine1 <> '' |
   Then
      LOC:ShippingAddressLabel = ' Shipping Address '
   Else
      LOC:ShippingAddressLabel = ''
   End

   ! Enable these.
   !---------------
   Toolbar11.SetEnabled (ID11_btnInsert, True)

   ?Insert {PROP:Disable} = False

   ! Click on the Insert button.
   !----------------------------
   Post (EVENT:Accepted, ?Insert)
Else
   ! The user canceled the search customer window.
   !----------------------------------------------
   If TranHed:CustNumber = '' |
   Then
     ! Make sure the user can't do anything until a customer is chosen.
     !-----------------------------------------------------------------
     ?SalesItemsList {PROP:Disable} = True
     ?TranHed:PaymentType {PROP:Disable} = True
     ?TranHed:PaymentAmount {PROP:Disable} = True
     ?CancelOrder {PROP:Disable} = True
     ?SaveAndPrint {PROP:Disable} = True
   End
End

Display()

 
Hi Emad,

You did not read my last post :

Since you are using :

SalesItemsList.SetFilter('1=0','9Z')

to erase the Browse, you need to use :

SalesItemsList.SetFilter(''[red],'9Z'[/red])

to reset the browse.

Regards

 
Hi ShankarJ,

I tried the SalesItemsList.SetFilter('','9Z') but still have problems. I did however discover the Erase command without parameters erases the browse as well.

I believe something in my "Save" button embed was causeing one of the problems so I removed all the code except for the message code to tell the user the transaction was saved out. I think something in the button that selects a customer is causing the form to out of add mode and nothing is saved to the transaction details. I will have to investigate that one further unless you see what I did wrong.

Truly.
Emad
 
Hi Emad,

Where are you setting [red]GlobalRequest = InsertRecord[/red]? It should be ideally on the first embed OR if you using this along with [red]Access:TransactionHeader.PrimeAutoInc[/red]
after [red]Opening Files[/red], the usage is :
Code:
SELF.Request         = InsertRecord
SELF.OriginalRequest = InsertRecord

Access:TransactionHeader.PrimeAutoInc

Regards
 
Hi ShankarJ,

Request and OriginalRequest did it!

Thanks.

It still looks like I have a lot to learn.

Truly,
Emad
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top