** No sls-discount record is available. (91) - progress-4gl

/*
sls-discount i sthe database name
*/Good day. I have another problem in regards again to value change of a specific browse.
my code for Add Button:
FIND CURRENT {&FIRST-TABLE-IN-QUERY-DIALOG-FRAME} NO-LOCK NO-ERROR.
IF AVAIL {&FIRST-TABLE-IN-QUERY-DIALOG-FRAME} THEN DO:
ASSIGN mode = 3.
ASSIGN BROWSE BROWSE-13:READ-ONLY = NO
sls-discount.dsc-amount:READ-ONLY IN BROWSE BROWSE-13 = NO
sls-discount.dsc-discount:READ-ONLY IN BROWSE BROWSE-13 = NO
sls-discount.log:READ-ONLY IN BROWSE BROWSE-13 = NO.
{&OPEN-QUERY-BROWSE-13}
IF BROWSE-13:num-iterations ne 0 then
BROWSE BROWSE-13:SELECT-FOCUSED-ROW().
BROWSE BROWSE-13:INSERT-ROW("BEFORE"). /*will cause value-change in browse*/
APPLY 'entry' TO sls-discount.dsc-discount IN BROWSE BROWSE-13.
RUN disp-enable.
END.
my code for browse-13:
ASSIGN xpromo-no = {&FIRST-TABLE-IN-QUERY-BROWSE-13}.promo-no
mdlrid = {&FIRST-TABLE-IN-QUERY-BROWSE-13}.record-id.
MESSAGE xpromo-no mdlrid VIEW-AS ALERT-BOX INFO.
OPEN QUERY BROWSE-16 FOR EACH sls.sls-disccount-model WHERE sls.sls-disccount-model.promo-no = xpromo-no
AND sls.sls-disccount-model.record-id = mdlrid NO-LOCK,
EACH sls.sls-model WHERE sls.sls-model.car-model = sls.sls-disccount-model.car-model NO-LOCK.
if I uncomment the entire value-change in a browse, it will display the message "** No DBName record is available. (91)" when clicking the add button. but if commented/removed, it will not display the message.
hope you can help me again .. Thanks

You've doubtless run into the infamous "partial field auto-completion" feature / bug. What that means is - if you cite a variable with no local definition for it, the Progress compiler will search all the available tables for a field that starts with the same sequence of letters and use that instead.
What the error is telling you is that the compiler associated a field with something in the "DBName" table, and when the code tries to access that variable, the DBName buffer isn't in scope - which is understandable since accessing it wasn't your intention.
My guess is that you've mis-specified a BROWSE construct. Looking at your first set of constructs, you've got two different forms:
BROWSE BROWSE-13:READ-ONLY = NO
sls-discount.dsc-amount:READ-ONLY IN BROWSE BROWSE-13 = NO
I'll bet one of these is wrong, and the compiler is associating the illegal "browse" citation with a field in DBName that starts with "Browse".
If you compile the code to an XREF file, it'll tell you which variable it's trying to associate with the DBName table. Correct that, and you'll be good to go.

I figure out what the problem on the code.. on click of Add button, the row inside browse-13 was arrange because of the {&OPEN-QUERY-BROWSE-13}. after that, because of BROWSE BROWSE-13:SELECT-FOCUSED-ROW(), it focused on the TOP date on browse and last, BROWSE BROWSE-13:INSERT-ROW("BEFORE"), created a blank data row at the very top. thus triggering value-changed of browse-13. on my value-changed on browse-13, the beginning of the code was to get current browse-13. since it was focused on the blank row, it resulted in an error with no query being found. sorry if i did not include the syntax get current in my first example.

Related

Finding the Name of a Range using VBA

Using VBA, how do you find the name of the range of an active cell (merged cells)? I have a worksheet that I have established a few named ranges. i.e. K7:R28 is a range of merged cells and is named "LocM11". I typed that into the Name box and it is already established. In my VBA code, if a user clicks on the merged cells of K7:R28 and presses a command button I want the code to return the name "LocM11" and save it as a variable to be used later in the code. I've looked everywhere but this has me stumped. Any advice is appreciated.
I've tried some code sniplets I found on the internet to no avail. I've found code that uses VBA to name a range, but I do not want to do that. I have the name established. I want to know the already existing Name and save it as a variable.
try this
Dim activeRange As Range
Dim rangeName As String
Set activeRange = ActiveCell.Range
rangeName = Application.Range(activeRange.Address).Name
Debug.Print rangeName
More details - https://learn.microsoft.com/en-us/office/vba/api/excel.application.range#example

How to explicitly save or close a recordset when a form deactivates?

I apologize if this is too vague a question, but we're having the following problem:
We use a search form to find a record, then load it in a bound-control form where changes are made. Then we return to the search form and open another record. When we do that, the form's BeforeUpdate property fires a 3020 error, "Update without Add New or Edit" and stepping through the code it's referring to the FIRST opened record. This is strange because there is no explicit update call, but after much trial and error I think the error is thus:
Record #1 is opened via the form and changes are made. Record #2 is opened on that same form without closing the first recordset. Even though we now re-opened the form with the second record, Access still assumes we're editing record 1, i.e. that we're trying to edit 2 records concurrently. Same as though we had a datasheet form and we edited one row and then tried to edit a second row without saving the first. What I want to be able to do is have it automatically do an update on the first record when the form deactivates so loading a new record doesn't cause this conflict.
So the bottom line is this: **Is there a way, on say the form's Dirty or Deactivate event, that we can force the form's recordset to update and close ** before loading a second record?
I hope I made this clear enough, it's a complex problem, so any small guidance would help. Btw, you may ask, "Why are you running the same code to open the same form twice?" Good question! Hey it's an old and badly written app (the thing has GoSubs in it for Pete's sake) but I have no choice but to make the best of a bad situation.
EDIT: I was asked to post code, which is reasonable, but it's in several different places. So I have the data form, it has a "Search" button to go back to the search form for opening another record. The search button on the data entry form is:
Private Sub CommandSearch_Click()
On Error GoTo Err_CommandSearch_Click
DoCmd.OpenForm "Reference Form", acNormal 'This is the form that does the searching
Exit_CommandSearch_Click:
Exit Sub
Err_CommandSearch_Click:
MsgBox Err.Description
Resume Exit_CommandSearch_Click
End Sub
When a record is selected on that search form, then the new form is opened with this code. Now this is where it gets tricky. I'm not the original programmer, as I said I think it was written in Access 97 by someone after taking an hour to read "Access for Dummies" :). But it always looks like only one copy of the form is open, so maybe it's re-opening it?
Public Sub CommandLoadCase_Click()
Dim LoadUTUCaseNumber As String, lengthUTUCaseNumber As Integer
lengthUTUCaseNumber = InStr(Forms![Reference Form]![Reference Query SubForm]![UTU Case Number], "-") - 1
If (lengthUTUCaseNumber = 0) Then
LoadUTUCaseNumber = ""
Else
LoadUTUCaseNumber = Left$(Forms![Reference Form]![Reference Query SubForm]![UTU Case Number], lengthUTUCaseNumber)
End If
On Error Resume Next
Forms![Case Appeal_Add-On Form].UTUCaseKeyToFind = LoadUTUCaseNumber
DoCmd.OpenForm "Case Appeal_Add-On Form", acNormal, , , , , LoadUTUCaseNumber
'Case Appeal Add On Form referred to here is the data entry form I refer to above.
End Sub
Finally, the Error 3020 (Update without Add/Edit) is occurring after it executes this line on the data entry form. (I know the code is complicated which is why I didn't enter it at first).
Private Sub Form_BeforeUpdate(Cancel As Integer)
[UTU Claim Sequence Key] = [UTU Claim Alpha Sequence] & CStr([UTU Claim Numeric Sequence])
End Sub

SharePoint REST: Column does not exist error

I'm calling a REST API with a SharePoint Designer workflow on SharePoint online. I'm setting the column name with a variable, and when i put the variable into my URL to call it it says "Column [name] does not exist".
Annoying part is when I call just /items? I can see the column in the result, but if I try select it or filter by it I get 'does not exist'. I have alot of these columns similarly named, and I get the error for all of them.
I am using the internal name, I have tried adding "OData_" to the front. I've tried typing the url manually in the browser and entering values (incase the variable was causing issues) but I get the same error, column does not exist. but i can see it them I call all items. :(
so I have quite a few columns with naming convention "[Q#] Score [#]" eg "Q4 Score 2". The internal name that's clearly appearing in the full items results is "Q4_x0020_Score_x0020_2".
This works:
https://MYSITE.sharepoint.com/sites/portal/intranet/CorpServices/QSR/_api/web/lists/GetbyTitle('Audit')/Items?
and I get big full normal REST results that includes the line:
0
However if I try:
https://MYSITE.sharepoint.com/sites/portal/intranet/CorpServices/QSR/_api/web/lists/GetbyTitle('Audit')/Items?$Select=Q4_x0020_Score_x0020_2
Then I get:
-2146232832, Microsoft.SharePoint.SPExceptionColumn 'Q4_x0020_Score_x0020_2' does not exist. It may have been deleted by another user.
I expect to be able to select that column (and the dozens like it) but none work. I've searched all similar problems on the forum and they've usually got a spelling mistake or forgot the ODATA_ but i cant seem to get the problem. Please help.
It seemed to be working intermittently.... So it was in fact just a naming error...... Half of the columns were [Q#]_x0020_Score_x0020_[#] and half were [Q#]_x0020_score_x0020_[#]. The word "Score" was capitalized on some and not others. I Didn't realize the HTTP Calls were case sensitive. Now I have added a bunch of if statements to handle the different variations haha. Thanks for reading.
Judging by the naming convention you are on an older version of SharePoint. The x0020 is the value for a space. Ideally when you first create the column you would name it without the spacing. For example UserInformation. Then come in and edit the name after the fact and call it User Information. If you click on the title name and look at the URL, you will see what the actual name of the column is at the end of the URL. It is case sensitive because you can have a column named score and Score which is ultimately why it wasn't working.
Must load all fields like this
var lists = context.Web.Lists;
context.Load(lists);
context.ExecuteQuery();
CamlQuery query = new CamlQuery();
query.ViewXml = #"";
var list = lists.GetById("file.guid");
var listitems = list.GetItems(query);
context.Load(listitems);
context.ExecuteQuery();
var creationInformation = new ListItemCreationInformation();
var newItem=list.AddItem(creationInformation);
var fields = list.Fields;
context.Load(fields);
context.ExecuteQuery();

Error in Opening Report from Form

I have a Form which will help me to filter out the records I want for my Report. The button will open the Report On Click.
This is the code in the button:
Private Sub Open_OEE_Click()
DoCmd.OpenReport "OEE_Report", acViewReport, , , acWindowNormal
End Sub
I keep getting the error:
I also have placed the query in my report under the Record Source as:
SELECT * FROM 3_OEE WHERE ((([3_OEE].RecordID)=Forms![3_OEE_Report]!cboRecordID) And (([3_OEE].Date_Recorded)=DateValue(Forms![3_OEE_Report]!Date_Recorded)) And (([3_OEE].MC_No)=Forms![3_OEE_Report]!cboMCNo) And (([3_OEE].Product)=Forms![3_OEE_Report]!cboProduct));
I want to search based on one criteria (text box or combo box) and not all four at once.
Am I missing out something?
MS-Access does tend to go a bit overboard with the brackets. Make the report's Record Source a bit easier to read by trimming out the unnecessary ones. You also need to get your date criterion in the right format - Access always uses US formatting in SQL queries and needs # signs around the date:
SELECT * FROM 3_OEE
WHERE [3_OEE].RecordID = Forms![3_OEE_Report]!cboRecordID
And [3_OEE].Date_Recorded = Format(Forms![3_OEE_Report]!Date_Recorded, "\#mm/dd/yyyy\#")
And [3_OEE].MC_No = Forms![3_OEE_Report]!cboMCNo
And [3_OEE].Product = Forms![3_OEE_Report]!cboProduct;
I would also suggest creating a named query for this and setting the report's Record Source to the named query. You can then test the query in isolation without having to run the report (but make sure the Form is open and the relevant controls are populated).
I asked for help from another source.
Answer to Question

MS Access implenting hyperlink like behavior for records to switch between forms

I'm currently working on a Database which requires the following functionality:
For example given a specific project, I have a series of structures which belong to that project, which are displayed in a datasheet view on the project form. I am attempting to allow the user to on double click to navigate to that specific structure which is displayed on another form. Currently I am using filters to implement this behavior, however, this results in the filter being left on, and when I manually turn off the filter, the form I switch to returns back to the first entry.
I am using the current code on the datasheet:
Private Sub struct_name_DblClick(Cancel As Integer)
LookupValue = Me.struct_ID
Form_frm_control.pg_structure.SetFocus
Form_frm_control.subform_structure.Form.Filter = "struct_ID = " & LookupValue
Form_frm_control.subform_structure.Form.FilterOn = True
End Sub
Any help would be greatly appreciated. Thanks in advance.
It all depends on what you need to do.
If you want to display all records and navigate to the selected record, then you can use bookmark navigation:
With Forms!MyOtherForm
.RecordsetClone.FindFirst "struct_ID = " & Me!struct_ID
If Not .RecordsetClone.NoMatch Then
If .Dirty Then
.Dirty = False
End If
.Bookmark = .RecordsetClone.Bookmark
End If
End With
This assumes that the other form is open with all the records loaded.
Another approach to this problem, which I find more useful for popup situations like this, is to just open the other form as a dialog and require it be closed before returning to the calling context. In that case, you'd do this:
DoCmd.OpenForm "MyOtherForm", , , "struct_ID = " & Me!struct_ID, , acDialog
You'd then have to close the other form to get back to the original context.
You might think that with large numbers of records this would be inefficient, but it's actually very fast, as this operation is highly optimized within Access (moreso than filtering an already open form, in fact).