I feel like I am missing a fundamentally easy process in Access right now.
I have 2 tables with different information on them. Table1 is client info Table2 is client orders. The primary key linking these two tables is the client_id. I made a form to input data into Form2. The form works and I can easily submit data to Form2 but I would like to add a read-only text box beside the client_id field that will display the customers first and last name (stored on Table1) to show the user that the client_id was typed in correctly. Am I going about this the wrong way or am I just missing something? Thanks for any guidance.
In the AfterUpdate event of the client_id field, use DLookup to lookup the client name, and set the value of an unbound, locked textbox to the name.
You can also fetch two fields into one expression:
Me.txtClientName = DLookup("[FirstName] & ' ' & [LastName]", _
"Clients", "client_id = " & Me.client_id)
Related
I do not know way which I can fill my form automatically. I mean that I made easy database which has just table. I made form too. User can write some information about herself/himself, for example name. If he/she end filling places to fill he/she should click send button and all information (expect ID - it gives admin) are on database. User can edit his/her information by clicking button - when he/she click it, it is possibility to write ID - when ID is ready, user can click button load data which fill all places by information connected with this ID.
I tried make some SQL query but it does not work. I past part of my code in window below, but I tried many combination of vba and sql - it always look very easy.
Private Sub button_wczytaj_Click()
OK_imie_wpr.Text = Select OK_imie from Karta_projektu where
Numer_projekt_wpr = Numer_projekt
Form.Refresh
End Sub
button_wczytaj - button which load my data.
OK_imie_wpr - it is place where user can write his name - for example: Tom
OK_imie - it is place where i hold name on my table.
Numer_projekt_wpr - it is blocked place, user get his/her project ID from admin.
Numer_projekt - it is place where I hold ID on my table.
Karta_projektu - it is name of table.
I expect that when I fill place for ID and click load button I get all data connected with my ID. Something like:
SELECT OK_imie from Karta_projektu where ID = [And here i need id which user just write].
select load Button Goto- Property- goto Event Propert- onlick Event-
'Assume your Textbox where you write your ID is Name as 'TxtID'
Dim Query1 as string
Query1 = "SELECT OK_imie from Karta_projektu where ID = " & Me.TxtID & " "
Me.Form.Recordsource = Query1
Me.Form.Requery
I hope you have created a Bound Form.
Table 1: My general information table
Organization: A lookup/relationship field that defaults to "N/A" but pulls values from...
Table 2: Organization List
No ID field, just the names of the organizations in the order which they were added
My data entry form has a combo box for organization and I would like it to update when I add an organization that hasn't been added before. I know I am supposed to use the "Not in List" event, but I don't know how to update the Organization list using this event. How do I do this?
Make sure the Limit To List property of the combo-box is set to Yes.
Add a On Not In List event to insert the value to your source table when a new value appears:
Private Sub MyComboBox_NotInList(NewData As String, Response As Integer)
With DoCmd
.SetWarnings False
.RunSQL "INSERT INTO [Organization List](Organizations) VALUES ('" & NewData & "')"
Response = acDataErrAdded
.SetWarnings True
End With
End Sub
Edit... nearly forgot... before I answer, what have you tried? :)
Edit 2... the example given is for a string value. Remove the ' from either side of New Data if it's a numeric value (but probably not if it's an organisation name).
Edit 3... The INSERT SQL is just one way of putting data into a table. You may prefer the RecordSet.Add and .Update methods.
I am currently attempting to design a database that requires a number of users inputting data via forms.
one of these tables is a 'user' table. Amongst the information in the table is
userid (int),
username (text),
first name (text),
last name (text)
In the even that I'm filling out a form and supply the the username in the username field is it possible if the username already exists to pull the first name and last name from the user table and auto-populate those form fields? If so can you point me in the right direction please?
Directly via access functionality or via vba? If not possible in 2003 is this possible in 2007?
Ok now for the auto fill (yes i did find one example), This will fill the username after you filled the userid (Both should be comboboxes in this case called Usernamecombo and useridcombo)
First make the query with a SQL similar to this:
SELECT [User].username FROM User WHERE ((([User].userid) Like '*' & [Forms]![Yourform]![useridcombo] & '*'));
Lets call this query "qry_username".
Then go to designview of the form and to the properties of the useridcombo, in the event/afterupdate property you make a event procedure (VBA) :
Private Sub useridcombo_AfterUpdate()
[Forms]![yourform]![Usernamecombo].Value = DFirst("username", "qry_username")
Forms("yourform").[Usernamecombo].Requery 'this last line is optional
End sub
Other fields can be added to the VBA pretty simply(dont forget the query)
Private Sub useridcombo_AfterUpdate()
[Forms]![yourform]![Usernamecombo].Value = DFirst("username", "qry_username")
[Forms]![yourform]![Firstnamecombo].Value = DFirst("Firstname", "qry_username")
[Forms]![yourform]![Lastnamecombo].Value = DFirst("Lastname", "qry_username")
Forms("yourform").[Usernamecombo].Requery 'this last line is optional
End sub
I have a similar form and i use to make these field as Comboboxes.
Then set the property row source as a query.
Set the criteria Where like this
WHERE ((([Users].Username) Like '*' & [Forms]![YourForm]![Username] & '*'));
This will allow the user to choose the name as fast as possible
But it will not fill it automatically because my users can have the same username as others.
To all salesforce experts i need some assistance. I have my contacts and a custom object named programs. I created a junction object using to master detail relationships with contacts and programs. I want to avoid relating the same contact to the same program. I tried triggers but I couldn't create the testing part to use it outside sandbox.
I went back to the basics and created a Unique text field. I tried to use default value but EVERYTHING i write in that crap is wrong -_-. I tried Contact__r.Email & "-" & Program__r.Name but to no avail.
I tried workflow rules with a field update but my field update NEVER runs.(Yes I did activate the workflow rule) and I didn't know what to write in my rule's code.
The workflow firing condition could be simply a formula that says true. Alternatively use "every time record is inserted". It also depends whether your master-details are set once and that's it or they will be "reparentable" (option introduced in Summer '12 I think). Maybe post a screenshot / text description of your firing condition? Also - is your unique field set to "case sensitive"?
As for the formula to populate the unique field - something like Contact__c + ' ' + Program__c (or whatever the API names of your fields are) should be OK. Don't use Contact__r.Email etc as these don't have to be unique...
You'll have to somehow fill in the uniqueness criteria for all existing records (maybe that's why you claimed it doesn't work?). If you can use Apex for data fixes - something like this should get you started.
List<Junction__c> junctions = [SELECT Contact__c, Program__c
FROM Junction__c
WHERE Unique_Text_Field__c = null
LIMIT 10000];
for(Junction__c j : junctions){
String key = String.valueOf(j.Contact__c).left(15) + ' ' + String.valueOf(j.Program__c).left(15);
j.Unique_Text_Field__c = key;
}
update junctions;
Keep rerunning it until it starts to show 0 rows processed. The Ids are cut down to 15 chars because in Apex you'd usually see full 18-char Id but workflows use 15-char versions.
I have been asked to look into FileMaker for creating a pretty simple database app. The application will handle contact information, some information about events hosted by the organization and - and this is where I'm currently struggling - RSVP information that link the contacts and events, as well as stores some data about payment.
What I would like to use is some kind of form where the user gets to search for a contact (any combo of first/last name) and an event (any combo of name/date), select each from two respective lists (where all other information is displayed as well, to distinguish the results), add some extra information and hit submit.
The closest I've gotten so far is a form where the user can enter a ContactId and EventId manually, which means that he/she first has to go to another view, search for the records, and copy/paste the id numbers.
Is there really no way to get closer to my vision using FileMaker?
Would a better option be to build a new, custom app using for example C# and MsSQL?
If so, how do I sell this to my contractor? As this would in that case be my first commercial application, there is obviously a "safety factor" that speaks in favor of an established product. And then we haven't even mentioned that the cost would probably increase, as developing a new app from scratch would take much longer time.
Note: I have no previous experience with FileMaker. I've tried to read the documentation, but I haven't been able to find any tutorials that take me closer to my specific needs. I'm fairly experienced in MsSQL, so I do know this and that about database management in general - just not in FileMaker.
There are loads of ways to do it. This is a quick way to get it to work.
Let's say you have two tables like this:
Contacts Events
-------- --------
ContactID EventID
FirstName EventDate
LastName EventDetails
Create a new link table between them that also stores the extra RSVP information you want.
RSVP
--------
fk_ContactID
fk_EventID
PaymentInfo
Create a FORM table
FORM
--------
ContactSearch
cContactMatch = Calculation, If(isEmpty(ContactSearch) ; "ALL" ; ContactSearch)
EventSearch
cEventMatch = Calculation, If(isEmpty(EventSearch) ; "ALL" ; EventSearch)
Add the following fields to the Contacts and Events tables:
Contacts
--------
cMatchField = Calculation, Stored, (FirstName + NEWLINE + LastName + NEWLINE + ALL + NEWLINE + Firstname LastName)
Events
--------
cMatchField = Calculation, Stored, (EventDate + NEWLINE + EventDetails + NEWLINE + ALL)
This means that the cMatchField for Contacts will look something like this:
John
Smith
John Smith
ALL
In the relationship diagram, connect the tables like this:
FORM
--------
cContactMatch = CONTACTS/cMatchText
cEventMatch = EVENTS/cMatchText
Create a layout called FORM based on the FORM table.
Add the fields ContactSearch and EventSearch to the layout. Add the PaymentInfo field.
Add two PORTALS to the layout, one for the Contacts table, one for the Events.
By default you should see all the records in each of these portals.
Write a script, or use a script trigger, that refreshes the layout whenever one of those search fields is Exited/Modified. This should refresh the portals and show you the related records you're interested in.
Add a button to each row in the portals and call a script that sets a global variable to that portal rows ID.
For example:
Script: Set Selected Contact ID
Set Variable ($$ContactID ; Contacts::ContactID)
Script Set Selected Event ID
Set Variable ($$EventID ; Events::EventID)
Add another button to the layout and a new script.
Script: Create RSVP
# Check that a contact and event have been selected
If(isEmpty($$ContactID) or isEmpty($$EventID)
Exit Script
End If
# Get the payment info that has been entered
Set Variable ($PaymentInfo ; FORM::PaymentInfo)
# Create the RSVP Link record
Go To Layout(RSVP)
Create New Record
Set Field(fk_ContactID ; $$ContactID)
Set Field(fk_EventID ; $$EventID)
Set Field(PaymentInfo ; $PaymentInfo)
Commit Records
Go to Layout (Original Layout)
# Clear the search fields
Set Field(PaymentInfo; "")
Set Field(ContactSearch; "")
Set Field(EventSearch; "")
Set Variable($$ContactID; "")
Set Variable($$EventID; "")
Commit Records
Refresh Screen
Phew.
And you should be back, ready to search for Contacts, Events, and "Submit" the form to create more RSVPs.
FileMaker is fun, eh?