Unable to get form to open to an existing record - forms

When my application first opens, I have an Autoexec Macro set to open a small form (frmGrantNo) in a window that asks for a grant number, the field for the grant number opens blank (Data Entry = On). This works.
Next I want to manually enter an existing Grant Number from my table (tblGrant), and open another form (frmInfo) to the grant number I manually entered.
So far, if I manually enter an existing Grant Number, I can’t get it to take me to that record in the frmInfo form, it opens to the first record in the table.
I have tried a Button Wizard for a Go To Record Button and I get the error “The command or action “Find” isn’t available now”.
I have tried a macro that opens the table (tblGrant), then Got To record, then Open Form (frmInfo) and it opens the table in datasheet AND the frmInfo Form, but to the first record, not the one I entered.
I have tried event procedures that I found online, but none of them work as I still don’t quite understand more than the basic VB commands.
I have looked here for help but I may not be working my questions right becuase I haven't found anything to help.
Any help would be greatly appreciated. ~ Thanks

You want something like this:
DoCmd.OpenForm "frmInfo", WhereCondition:="GrantNumber = " & Me!GrantNumber
in the button event procedure. It filters the opened form to the grant number you entered. Adapt field names for your table and form.

Related

Increment Id in Sharepoint

I am trying to increment an Id in a Sharepoint list.
I have tried different settings in the online editor of Sharepoint under "Settings > List Settings > Edit Column > Calculated Value".
Another option I tried was to create a custom add form using InfoPath.
In this custom form, I added a rule on my field contactId. The rule has two actions.
Create a Query to the Contacts table
Set the current Id equal to (the maximum idContacts + 1)
enter image description here
A thirth option I tried is to set a rule under Submit options. That way I thought when I submit my form it will check if idContacts is currently blank. It will Query the Contacts table, set the current idContacts as the (maximum idContacts + 1) and finally submit the data to my table.
enter image description here
Finally When I submit my form it gives a pop up message "Connecting to Server" then it redirects to my list but nothing is added to the list.
Does anyone know what my problem could be. Or does anyone know a proper way to do this. I already lookup up a lot of tutorials and other information but I can not find it.
Thank you in advance!

Open form to record seleced from double click on same record in datasheet form

I've got a pair of forms that are both based on the same data table. One is a single form with a better layout of all the onfo, the other is a datasheet. I want to be able to double click on the project number in the datasheet form to open the details single form to that same record.
I've done it on a simplified practice db, but when I try it in my current db it opens the second form, but to a new record entry. This form is one that was a template that someone else downloaded and modified for our purpose, so maybe there is something stored somewhere else that is interrupting the filtering.
I deleted a couple of macros that I thought might be interfering, made sure that the form properties are cycling all records and that on form load it isn't directed to a new record. I can't figure out where else there is something preventing the form from being filtered for the selected record. Here's the code I've used in the datasheet form:
Private Sub combined_DblClick(Cancel As Integer)
DoCmd.OpenForm "frmTaskDetailsExisting", acNormal, , "SLRtaskID = " & Me.SLRtaskID
End Sub
Anyone have an idea what I'm missing here.
Have you considered doing this with a split Form? You will have the Detailed view per record and the dataseet.
If you really want two independent forms due to your needs, your code looks ok. But two things may be happening:
The value in Me.SLRtaskID is not correct. Put a breakpoint in the code and check it.
There is code in frmTaskDetailsExisting that moves it to a new record when it is opened, regardless to the filter.

Move to next record recordset after query in access vba

This is my first question but I have to say that is not the first time that I've used the site. One more thing, sorry for my english...
I'm working on a project in Access 2007 with a lot of VBA code and a lot of forms to the front end. In the forms I've included record navigation buttons for the user to move between the different records of the table (next, previous, etc).
However, I have a problem I do not know how to fix. Imagine that the user enters a form. Naturally, the form shows the 1st record contained in the table. In the form, the user can search a record and go to a specified record.
After getting that record, the user presses the button to display the next record. However, instead of going to the next, it goes to the record after the 1st. In other words, the form goes to the 2nd record.
I guess it's because recordset of the form hasn't been updated, so when the user presses the next button (actually I am doing a docmd.gotorecord acNext), it goes to the next record that is in the table (the 2nd record).
I tried updating the recordset after making the query though the form recordsource method, but nevertheless it continues to go wrong ...
What would be the most practical solution?
Thanks!
Your issue comes from the fact that when you set the filter to false, you actually re-set the entire form.
To get around this, you can try this for your search command:
DoCmd.OpenForm "Customers"
' This assumes that you've got a control on the customers form named ID which has the IDs in it
DoCmd.GoToControl "ID"
DoCmd.FindRecord Me.search_customers_subform.Form.ID
And when clicking next, all you need now is:
DoCmd.GoToRecord , , acNext
The filter doesn't exist anymore.
Hope this works for you. I don't have Access on me right now so this code is mainly from memory, if there's any problems, feel free to ask.

Access Form won't accept input in text boxes

So I have a form in Access.![acessform1][1]
Here are form properties
I got this database and have been making adjustments to the other forms. I gave the database back to the user and they reported an issue that this form is not acting properly, and the add order record function is not working anymore.
There's an Add Order Record button on the right side of the form that would usually add the record if the user manually entered input into some of the boxes. The old form you would have control of the values 1/0 for yes/no. You can enter text into the notes boxes.
This functionality doesn't work anymore, and I can't seem to figure out why. The form is identical to the original and no adjustments have been made except to the table that it pulls data from.
So the symptoms are:
User input is not accepted in text boxes.
The find CP functionality works with the drop down and reflects the records accurately but I cannot update the fields.
Also, the fields CP_Ref and Invoice date don't let me enter data anymore.
Also the Add Order Record was giving me an error that The it could not find the record specified, but I since copied the original form back into place and that error went away.
I think functionality wise this button should save the record after a field is updated and should add a new record.
Seems like all the controls are locked on the page.
Here is the query that pulls the data when I click the button that takes me to the Order form.
SELECT DISTINCTROW CPOrders.Cust, Customer.NAME, CPOrders.CP_Ref, CPOrders.Slsman,
CPOrders.Date_opn, CPOrders.CPSmall, CPOrders.InvIssu, CPOrders.InvNo,
CPOrders.InvDate, CPOrders.DueDate, CPOrders.ETADate, CPOrders.Closed,
CPOrders.Cust, CPOrders.Name, CPOrders.BuyerRef, CPOrders.ToCity,
CPOrders.ToState, CPOrders.ToCtry, CPOrders.ToPort, CPOrders.Supplier,
CPOrders.Origin, CPOrders.Product, CPOrders.GradeType, CPOrders.NoUnits,
CPOrders.Pkg, CPOrders.Qty, CPOrders.TotSale, CPOrders.TotCost,
CPOrders.GrMargin, CPOrders.[Sale$/Unit], CPOrders.[Cost$/Unit],
CPOrders.OceanCost, CPOrders.OceanNotes, CPOrders.BLadingDate,
CPOrders.USAPort, CPOrders.FOBCost, CPOrders.FASExportVal,
CPOrders.InlandFrt, CPOrders.CommodCode, CPOrders.Notes,
CPOrders.ProjCust, CPOrders.ProjValue, CPOrders.ContainerNumber,
CPOrders.Vessel, Customer.TERMS
FROM Customer INNER JOIN CPOrders ON Customer.[CUST_#] = CPOrders.Cust
ORDER BY CPOrders.CP_Ref;
I ended up checking several locations for the answer to this.
What it ended up being was a primary key issue.
Essentially when I got the updated database I put them into new tables, effectively destroying the dependencies, relationships, and established keys.
I reverted back to the old tables and found out the form worked properly.
The issue ultimately was that the primary keys were not defined as needed for the table to be updated.

How can I create a new primary key in a FileMaker table and then modify an existing relationship to be based on the newly created key?

I have quite the request. A developer created our database that has multiple Layouts with a relationship tree that is very messy. Had another developer come in, take a look at it, he said that it would be too time consuming and painful to deconstruct our system, consider creating a script for now so that you can work around it until it can be fixed. Here's the dilemma: I've got information on one page that is supposed to reference information on a number of different pages utilizing tabs and portals. However, all the information is linked to a username. This username is not static/serialized or what have you. Therefore, if the issue is not caught right away a great deal of information can be linked to this person's 'page'. If the name is incorrect and someone tries to alter the username even slightly, it breaks that relationship and starts a new one. The information does not disappear, but it is basically sitting in limbo somewhere until you change the name back to the original. I've actually tried exporting the information, changing the information that doesn't match, i.e. changing a name from Jon.Smith to John.Smith, and then importing the information to a new 'page' for that person with unsuccessful results. Which brings me to my question, is a script going to be able to fix this problem? Likewise, are there any suggestions to how to create this script? I apologize, but I have very little experience with DataBase management at all, and am not sure why this project fell upon me. Any help would be GREATLY appreciated.
Well, as a general answer, just about anything that a user can do in FileMaker (and by user, I mean non-developer, so activities such as defining the database structure, writing scripts, etc., are excluded) can be scripted. So if you're able to "solve" the problem by resetting a field's value, for example, then, yes, a script can do that.
Regarding your specific trouble, a script probably doesn't need to export the records, but could reset the values for the field within FileMaker. This could be done either by looping through the records that need to be changed or by using the Replace Field Contents script step. So a script could do something like this:
Go to Layout[MyLayout] // Go to a layout that is attached to the table you need to search.
Perform Find[Restore] // Restore a find that will show the records you need to change.
Replace Field Contents[Table::Field; "New Value"]
Offering more advice than this would require actually seeing the database and understanding more about your specific needs.
wchsTech4, you are in luck because your problem is easy to fix. You don't even need a script.
BACK UP YOUR FILE(S) FIRST. Then:
1) Create two new fields:
id (person table)
Options for id: Auto-enter serial number
person_id (the table related to person)
2) Generate serial numbers for the new id field in the person table.
Navigate to the person layout.
'Records' > 'Show all records'
Click in the id field and select 'Records' > 'Replace field contents.'
Choose 'Replace with serial numbers' and accept the defaults. Be sure to check the box to update your next serial number.
3) Place the serial numbers you just generated in the related table.
Navigate to the related layout.
'Records' > 'Show all records'
Click in the person_id field and select 'Records' > 'Replace field contents.'
Choose 'Specify' next to 'Replace with calculated results.'
In the drop down on the top left, select the related person table.
Double click the id field (your calculation should be person::id, with person replaced with the name of your table).
Click 'OK' and then 'Replace.'
4) Change the relationship.
Select 'File' > 'Manage' > 'Database.'
Navigate to the relationship tab.
Change the relationship from being based on name to id.
5) Test everything. Should work.
There is a chance that your related records are being created in such a manner that you also need to modify a script, website, or something else not mentioned here to have your fix work going forward. That is important to investigate.