Form Opens blank in form view - ms-access

I have a database system that logs calls for a department. All the calls for today are displayed on a main form in a list box. When a record is double clicked the call can be opened to view the information. This information is stored across two tables by a intermediate relationship.
When the form is opened in design view all the controls are visible. As soon as it goes to form view or a record is attempted to be opened, the form opens blank.
This has happened since i added the information from the second table. What has gone wrong?
Here is the query.
SELECT
TBL_CallsDB.ID, TBL_CallsDB.Agent_No, TBL_CallsDB.Agent_Name,
TBL_CallsDB.Call_Date, TBL_CallsDB.Call_Time, TBL_CallsDB.Caller_Type,
TBL_CallsDB.Call_Type, TBL_CallsDB.[Company Name], TBL_CallsDB.[Company Contact],
TBL_CallsDB.Caller_Name, TBL_CallsDB.Phone_No, TBL_CallsDB.Cell_No,
TBL_CallsDB.Fax_No, TBL_CallsDB.Email_Address, TBL_CallsDB.Address,
TBL_CallsDB.City, TBL_CallsDB.State, TBL_CallsDB.[Zip Code],
TBL_CallsDB.Details, TBL_CallsDB.Action_Resolve, TBL_CallsDB.Resolve_Date,
TBL_CallsDB.Resolved, TBL_CallsDB.Attachments, TBL_CallsDB.Status,
TBL_CallsDB.Memo, TBL_Units.Technology, TBL_Units.[Serial_No#],
TBL_Units.Model, TBL_Units.[Model_No#], TBL_Units.Unit_Type,
TBL_Units.Install_Date
FROM TBL_CallsDB
INNER JOIN TBL_Units ON TBL_CallsDB.Agent_No=TBL_Units.[Agent No];

Examine the values stored in TBL_CallsDB.Agent_No and TBL_Units.[Agent No]. The query's join condition causes it to retrieve only those rows with matching values in Agent_No and [Agent No]. But none of those existing values match, so the query returns no rows.

Related

How to update multiple records in same table using .AfterUpdate data macro without error "A data macro resource limit was hit."

I have a table tblItems with a list of inventory items. The table has many columns to describe these items, including columns for SupplierName, SupplierOrderNumber and PredictedArrivalDate.
If I order several new items from a supplier, I will record each item separately in the table with the same supplier name, order number and a predicted arrival date.
I would like to add a data macro, so that if I update the PredictedArrivalDate for one record, the value will be copied to the PredictedArrivalDate column of other records/items with the same SupplierName AND SupplierOrderNumber.
The closest I've got is:
SetLocalVar (MySupplierName, [SupplierName])
SetLocalVar (MySupplierOrderNumber , [SupplierOrderNumber ])
SetLocalVar (MyPredictedArrivalDate, [PredictedArrivalDate])
For Each Record in tblItems
Where Condition = [SupplierOrderNumber] Like [MySupplierOrderNumber] And [SupplierName] Like [MySupplierName] And [PredictedArrivalDate]<>[MyPredictedArrivalDate]
Alias OtherRecords
EditRecord
SetField ([OtherRecords].[PredictedArrivalDate], [MyPredictedArrivalDate])
End EditRecord
However, when I run this, only 5 records update, and the error log reports error -20341:
"A data macro resource limit was hit. This may be caused by a data
macro recursively calling itself. The Updated() function may be
used to detect which field in a record has been updated to help
prevent recursive calls."
How can I get this working?
I'm not one for using macro's to do anything, so I'd use VBA and recordsets/an action query to do the updating.
You can call a user-defined function inside a data macro by setting a local var equal to its result.
Access doesn't like data macros triggering themselves (which you are doing, you're using an on update macro and updating fields in the same table on a different record), because there is a risk of accidentally creating endless loops. Looks like you triggered a measure that's made to prevent this. I'd try to avoid that as much as possible.
Note: using user-defined functions inside data macros can cause problems when you're linking to the table from outside of Access (via ODBC for example).
This isn't a good solution (it's not a data macro), but it does work as a temporary fix.
I created an update query called "updatePredictedArrivalDate":
PARAMETERS
ItemID Long,
MyPredictedArrivalDate DateTime,
MySupplierName Text ( 255 ),
MySupplierOrderNumber Text ( 255 );
UPDATE tblItems
SET tblItems.PredictedArrivalDate = [MyPredictedArrivalDate]
WHERE (((tblItems.SupplierName) = [MySupplierName])
AND ((tblItems.SupplierOrderNumber) = [MySupplierOrderNumber])
AND ((tblItems.ID) <> [ItemID]));
On the PredictedArrivalDate form field .AfterUpdate event, I then added this macro:
IF [PredictedArrivalDate].[OldValue]<>[PredictedArrivalDate] Or [PredictedArrivalDate]<>""
OpenQuery (updatePredictedArrivalDate, Datasheet, Edit, [ID], [PredictedArrivalDate], [SupplierName], [SupplierOrderNumber])
I now have to remember to add this .AfterUpdate event to any other forms I create that amend that particular field.
If anyone has a better solution, please let me know.

Editing a Form in MS-Access

I am working with MS-Access and I have created a Form(1) that consists of data from a Query(1) and a subform with data from a Table(2). Along with that, I have the Form(1) in a Split Form View displaying the datasheet at the bottom. The problem I am having is that I want to be able to completely edit everything as well as Add New Records(main problem) in the Form but, Access is not allowing me too. To understand my problem better, I have added some descriptions of the tables and attached some images below:
Table 1: Sales -
Fields: SalesID(AutoNumber), Customer(Short Text), and Date(Date/Time)
Table 2: Transaction -
Fields: TransactionID(AutoNumber), SalesID(Number), Sales(Currency), Cost(Currency), and Profit(Calculated, Currency -> [Sales]-[Cost])
Relationship: Table 1: SalesID(one) -> Table 2: SalesID(many)
Query 1:
Form 1:
I created a form/subform arrangement like you describe. No problem adding new record. However, getting the aggregate query to update requires code to requery the form's data. So in the subform's AfterUpdate event:
Sub Form_AfterUpdate()
Me.Parent.Requery
End Sub
One drawback to this may be that focus will be returned to first record of the main form.
UPDATE: Learned something new - Me.Parent.Recordset.Requery will not return focus to first record.

Populating a form with a dropdown - Access

I am trying to create a form in access that has a dropdown at the top and will populate the rest of the form with the record that corresponds to what is chosen.
I have looked at 2 different guides online but both point to older versions of Access and I think I am missing something.
So. The order that I did everything:
I went to the table for the form. And I clicked Form. This made a quick form with all of the fields as text boxes.
I deleted the field that will be the dropdown and I put in a dropdown canceling the wizard
In the data section for the dropdown. I edited "Row Source" to select the field that will be in the dropdown and the unique ID, in that order.
I set the bound Column to 2 (I have tried both)
I set the name of the Combo Box to "TitleSelector"
In Form Settings. For "Record Source". I have "[forms]![Edit Piece].[TitleSelector] & "*" in Criteria for "ID". I also have the rest of the fields in the Query listed
I added the "me.requery" to on change
Not sure if it means anything. When I was typing in the Criteria for "ID" it did not show "TitleSelector" in the drop down.
I am using Access 2010
Edit:
My Problem -
The dropdown itself shows everything correctly. However nothing happens when I choose something
Edit:
SELECT Pieces.ID, Pieces.Title, Pieces.Composer, Pieces.Instrumentation, Pieces.Location, Pieces.Location_2
FROM Pieces
WHERE (((Pieces.ID)=[forms]![Edit Piece].[TitleSelector]));
Edit:
Here is a link to a copy of my database: https://www.dropbox.com/s/tpnqm686tj653fg/Trisha%20Database.accdb
Adding the me.requery to the ON CHANGE EVENT
(select CODE BUILDER - and enter the me.requery there) should work.
I have downloaded the sample file. Your problem is that the Record Source for the [Edit Piece] form is set to...
SELECT Pieces.ID, Pieces.Title, Pieces.Composer, Pieces.Instrumentation, Pieces.Location, Pieces.Location_2 FROM Pieces WHERE (((Pieces.ID)=[forms]![Edit Piece].[TitleSelector] & "*"));
...and the & "*" at the very end is causing the query to return no records. Removing that last bit so the Form's Record Source is...
SELECT Pieces.ID, Pieces.Title, Pieces.Composer, Pieces.Instrumentation, Pieces.Location, Pieces.Location_2 FROM Pieces WHERE (((Pieces.ID)=[forms]![Edit Piece].[TitleSelector]));
...gets your form working.
Edit
To have your form display information from the related tables (instead of just the foreign key values from the [Pieces] table), change the Record Source of the Form from...
SELECT Pieces.ID, Pieces.Title, Pieces.Composer, Pieces.Instrumentation, Pieces.Location, Pieces.Location_2 FROM Pieces WHERE (((Pieces.ID)=[forms]![Edit Piece].[TitleSelector]));
...to...
SELECT Pieces.ID, Pieces.Title, Composer.Composer, Instrumentation.Instrumentation, Location.Location, Location_1.Location AS Location_2 FROM (Location INNER JOIN (Instrumentation INNER JOIN (Composer INNER JOIN Pieces ON Composer.ID = Pieces.Composer) ON Instrumentation.ID = Pieces.Instrumentation) ON Location.ID = Pieces.Location) INNER JOIN Location AS Location_1 ON Pieces.Location_2 = Location_1.ID WHERE (((Pieces.ID)=[forms]![Edit Piece].[TitleSelector]));

Setting the APP_USER as a value to be passed to target page in APEX

I'm making a student management system on apex. The short of it is a place where lecturers and students can log on. Lecturers create assignments, assign them, mark them, take attendance, record issues ...... all that, and students log on to view their attendance and results.
Now when a student clicks the "My Results" link it navigates to the same page that a lecturer sees, though the select list where a student is selected to view the results of is hidden. The select list displays the students name and returns the id for that student, which also happens to be the user name for a student to log in.
So i want to pass the value of the app-user when a student clicks the link so that only their results are shown.
I've tried to set
these items
:P10_SELECT_STUDENT
with these values
#APP_USER#
which works but no the message "no data found" is shown.
Just for testing i've set that select list to be displayed for a student, and when the page loads it loads with the null value at the top of the list which is
display value
select a student
return value
-1
I've gone and manually set the value passed to be the id of the test student. works a treat, the data loads for that student!!
So does anyone know why the #APP_USSER# value im sending isnt being set in the listbox
Thanks in advance
What you need is the session state of the APP_USER variable. In a query you would reference this with :APP_USER. When you need to pass on the value as a parameter for, for example, a link, you would use the substitution string notation &APP_USER. Much the same way you would refer any other variable/page item.
For example, setting up a button:
A good page to read up on Substitution strings: Application Builder Concepts
The hash-sign notation is commonly used for non-plsql-variables substitution, like the value of a column in report when passed through in a link,
Zac,
If the users haven't authenticate themselves then the :APP_USER parameter is null. If the user authenticated via a SSO, or via DB credentials or whatever you have in the application then the :APP_USER will get populated.
Here is what i understood :
In page 12 , P12_STUDENTS is a select list, and you want it to reflect the current student if he enters or the full list if he's a teacher right?
You don't need to pass :APP_USER via a link or a branch or whatever. It exists as a global Apex variable and is visible in page 12 via :APP_USER but again , its null if the user is not authenticated.
Your select list source should be like:
select display d, return r
from table
where (:APP_USER is NULL
OR (:APP_USER IS NOT NULL AND :APP_USER = student))
tell me if this helps?
regards,
Alex

Restoring original values

I have a form in which we are showing customer records in a grid.User clicks a row, and in a new form record is shown.After editing some values, user may click cancel. if so, in grid we need to return to original values.
How can I restore the original state of the entity.We are using linq-to-sql, and grid is bounded to List.One way I see is,using getoriginalentitystate method.
If a user cancels a process, no change is made at the Database and the control reverts back to the pre-action state. This is a normal and built-in behaviour.
In case, if this is not happening, try rebinding List to it's DataSource, like
myList.Databind()
As the user is entering data in the form, the values should be stored in your UI layer (not written to your "database"). The data in the form is held there temporarily until the user clicks 'OK'/commit. If the user clicks 'cancel' the form is simply discarded and not written to the database.
Until the user hits 'OK', the original data is still in the database. You can get the original values there.