Forms :: TextBoxes Getting Information From Queries (DLookup)
Aug 4, 2014
Retrieval of data from a query and putting it into a textbox on a form. I currently have a form where I would like to put in a Job Number, and then hit an "Update" button and it will show some of the data fields associated with that Job Number. I have a table called "All Jobs" and each Job Number is unique. Where I'm really having issues with is in regards to Dates and Boolean fields.
In one form, I put in a job number and it will bring up the Company, Motor type, Received Date, and Quote. I have been able to retrieve the Company, Motor, and Quote with a DLookUp expression using a query. The expression looks like:
CompanyName.Value = DLookUp("Company","Approved Job Form - Find Job Info").
CompanyName would be the name of the textbox on the form, with "Company" the field within the "Approved Job Form - Find Job Info" query. The query itself uses the job number entered onto the form and returns the other data fields associated with that job number. Running the query by itself returns the correct information. My issue comes with using the Date Received field. It seems that because that field type is a Short Date, my DLookUp expression keeps prompting the debugger in the code. Currently I have:
RcvDate.Value = DLookUp("Receive Date","Approved Job Form - Find Job Info")
This will not bring the date from the query into my text box like the others.
In another form, I'm also having issues with a Boolean data field. I would like to have a query that looks up a job number, and if my data field (Job On Hold) is checked (True), I would like it to return a value of "Job On Hold / In Progress" into a text box. If it is unchecked (False), I would like it to return "Job Approved". I've tried a bunch of different ways to make it work, but I'm really stumped. The makeshift code I last tried (I've tried this numerous ways, so I'm not sure if I was closer before) is:
Dim jobstatus As Boolean
jobstatus = DLookup("Job on Hold", "Job Status Form - Search Status")
If jobstatus = False Then
Status.Value = "Job Approved"
Else
Status.Value = "Job On Hold / In Progress"
End If
View Replies
ADVERTISEMENT
Apr 26, 2005
OK, this is my first post and unfortunatly it is for some help...
I have searched Google to my wits end without any luck.
Heres my problem (partially) and I am hoping some kind person can help me.
Suppose I have a form [form1] and a query [query1].
On form1 I have a 2 textboxes. [txtProduct] and [txtStockCount].
Into [txtProduct] I enter the name of a product. In reality I have already a usable listbox in my form, but I am using a textbox for simplicity here!
Now I create an [EventProcedure] using 'On Lost Focus' against [txtProduct].
The event prodedure would partially read:
"SELECT query1.StockTotal, query1.Product FROM query1 WHERE = Product = txtProduct;"
In my actual form I am using a listbox with a listbox.rowsource = (SQL Query)to display the stock count, but I don't think this is the best way... (It works, i'll give it that!).
What I would ideally like to do is take the results from that aformentioned query and display them in txtStockCount.
What I am aiming for is to get the a query to dump its single result into a variable; not just for display purposes (txtStockCount), but to later validate user input when they wish to reduce stock values from the database, IE so they cannot produce negative stock counts.
I have a feeling this might involve Record Sets which I know nothing about at present.
If someone could either provide some working sample code snippet or point me in the right direction I would appreciate it.
I am confident enough to write SQL statements. I am semi confident in using VBA. (I am not a complete newbie).
If I have not been clear enough, I can provide a lot more information using actual details from the database I am trying to develop.
The database is a stock control system which records:
* products in one table
* transactions in another table (goods in and goods out)
* a query to 'sum' up 'goods' in and 'goods out' with an expression to create total stock counts for each item
* a form into which a user can select an item from the product table which would then produce a single count of the stock running another SQL query against the one already created to pick out that single product (phew!)
and finally in the same form add to the transaction table.
Here's hoping!
Damo.
View 6 Replies
View Related
Mar 22, 2013
I have 3 table table; Invoice table, Product table and Sale_product table. Sale product table records all sale from the product table
Invoice table has these fields
ID
TOTAL
CASH_TENDERED
CHANGE
Product table has
ID
CODE
QUANTITY
NAME
PRICE
and Sale_Product table has these
ID
PRODUCT_CODE
QUANTITY
PRODUCT_NAME
PRICE
SUBTOTAL
INVOICE
I did main form from Invoice table and sub form from Sale_product table. I want to use DLOOKUP function to load the name and price, quantity and calculate subtotal automatically from the product table based on the product code entered. i have being trying hard and i keep on getting "Name? error"
View 1 Replies
View Related
Jan 27, 2014
I've tried manipulating my code in always but cant solve my current issue.My 3 tables are Clientdetails, Clientcontact and Clientdoctor.All the lookups below work fine. clientname is a textbox i use to search the Database and populate my form unbound. i want to populate other textboxes with data from Clientcontact table as well. I'm using a command button relevant to the clientname search.
D = DLookup("[ID]", "[Clientdetails]", "[Surname] ='" & [Forms]![unboundfrm]![clientname] & "'")
Forename = DLookup("[Forename]", "[Clientdetails]", "[Surname] ='" & [Forms]![unboundfrm]![clientname] & "'")
Surname = DLookup("[Surname]", "[Clientdetails]", "[Surname] ='" & [Forms]![unboundfrm]![clientname] & "'")
Address1 = DLookup("[Address1]", "[Clientdetails]", "[Surname] ='" & [Forms]![unboundfrm]![clientname] & "'")
Address2 = DLookup("[Address2]", "[Clientdetails]", "[Surname] ='" & [Forms]![unboundfrm]![clientname] & "'")
[code]...
View 1 Replies
View Related
Dec 31, 2004
Im just starting to program in Access.. can somebody please help me with my problem?
Im trying to figure out how to search the table with the content of my textbox. (Ex. i input "A" in my textbox, it should display all the records of "A" like it's AGE, STATUS, etc.) it doesn't have to be case sensitive or exact because i have a primary key that doesn't accept duplicate.
Thanks to anyone who'll help
View 3 Replies
View Related
May 16, 2014
I have a continuous form and having trouble with the layout. When i fill in the record and then tab to the new record it displays the textboxes on top of the last one instead creating a new line bellow?
View 2 Replies
View Related
Oct 21, 2013
I've got a form called "Main Menu" and i'm in the process of implementing a search form into it. So far I have three textboxes called TBFirstName, TBSurname and TBCentre these are unbound. I also have a search button.
This button runs the query which runs the search, the sql for this query is below.
Code:
SELECT Staff.[Employee ID] AS [Staff_Employee ID], Staff.Forename,
Staff.Surname, Staff.Sex, Staff.[Job Role], Staff.[Start Date], Staff.[Leave Date], Staff.Centre,
Staff.Hours, Qualifications.[Employee ID] AS [Qualifications_Employee ID],
Qualifications.[Level 2 Maths], Qualifications.[Level 2 English], Qualifications.[Level 3 Support Maths],
[Code] ....
Whenever I run this query it just returns all the records instead of the search criteria. Where am I going wrong?
View 14 Replies
View Related
Dec 16, 2013
When moving to a new a record in my form, i will click on a text box and the following happens:The black line will flash much faster than normal (This will happen on any text box i click on) No text will appear while this is happening When it stops al the text that was typed in that period will appear After this 5 to 10 second text delay the text box and all other textboxes will work fine, until i move to a new record and the process starts again
View 2 Replies
View Related
Jul 24, 2015
I haven't been able to find if there is a maximum length of text within a textbox.
I have a form on a club database, and one of the textboxes has the details of their photographic experience. I have one person who is a very experienced worker and I need to add more details in the textbox. Currently there are 29 characters, including spaces in the box, but it won't allow me to add any more. I have set the width of the box on the form to a wider setting, but this makes no difference. What can I do?
View 5 Replies
View Related
Oct 12, 2014
I have three textboxes , textbox 1,textbox 2, and textbox 3, I can change the value of textbox 3 based on the date of textbox 2 by using
if me. textbox2 < date then
me. textbox 3 ="expired"
end if
but I need it to look at textbox 1 as well and only change textbox 3 to "expired" if both conditions are true. example
if textbox 1 = "abs" and
textbox 2 < date
then textbox 3 = "expired".
end if
View 10 Replies
View Related
Aug 28, 2014
When a user selects a name from a combo box then 11 textboxes are populated with personal information.
What I am looking for is when the user edits the persons information (i.e. changes the persons phone number to a different number), how do I update the table with this information?
Is there a way to only update fields that have changed? or do I have to save all textboxes?
I have read about an "Update Query" and a SQL Update, but I did not think the two applied. I am sure that I am wrong, lol.
I tried the "Docmd.Runcommand acCmdSave (in the OnClick event cmd button) but it did not make any changes to the table.
This is what I put in the OnClick event:
Code:
Private Sub cmdSaveEdit_Click()
DoCmd.RunCommand acCmdSave
TextBoxLockDown
Me.Requery
End Sub
View 2 Replies
View Related
May 24, 2013
I have a form with checkboxes, indicating fields which can be selected for a query. The strSQL variable works fine, and I can use QUERYDEF to create a query from the variable.
I wonder if it is possible to generate a form to display only the fields chosen - i.e. I don't want a general form with all fields, with only the chosen ones displaying data. Instead, if I select only 5 of the 10 fields, I want the form only to show those 5 fields.
Creating textboxes for each field, and using the .visible property, but then I would have lots of gaps on the form.
I hoped it might be possible to use a loop with a value set something like
For i = 1 to fieldcount
textbox(i).recordsource = selectedfld(i)
'somehow know where to place the textbox!?!!
Next
View 14 Replies
View Related
Apr 9, 2013
I'm trying to make a template form for a helpdesk, at the bottom would be a "Copy to Cliboard" button that when pressed will copy to clipboard in the format of:
label1 textbox1
label2 textbox2
label3 etc...
I got the jist of it, but got lost somewhere along the way, this is what I have so far:
Code:
Option Compare Database
Option Explicit
Private Function fcopyfields() As String
Dim strapp As String
Dim strapplabel As String
[Code] ....
It's falling apart at the button click.
View 2 Replies
View Related
Dec 12, 2013
I have a form to input info into a table how can I combine 2 txtboxes to one column separated by ", "
Example:
textboxes:
txtboxFirstName txtboxLastName
output:
Last, First
into the "Name" Field in my table
View 1 Replies
View Related
Sep 5, 2013
I have a form and I am not sure of the best way to populate the multiple fields on it.
The form consists of a textbox to select a date (txtDate) and then once this date is selected I want the multiple textboxes on the form to be populated from data I have in a table.
The name of each textbox is a concatenation of "txt" the number of the person which is a number from 1 to 4 and then a time eg for 12 Noon it would be 1200 so the textboxes are from txt10800 to txt42000 i.e. each person has textboxes from 8.00am to 8.00pm in half hour intervals.
I need to use two tables to populate these textboxes as in the main table there are codes that have a relationship to fields within another table that holds attributes for that code. (eg code 123 could equal Service A in the second Table but 123 is what is held on the main table) Also in the main table I have a calculated field that creates the name of the relevant textboxes on the form.
If there is a textbox that will not be populated as there is nothing in that time period then I would like this to be left blank or Null.
Am I best creating a query and binding the form to this query or to leave it unbounded and use a recordset within VBA
Also what is the best way of using either
I am using Access 2013...
View 5 Replies
View Related
May 3, 2013
no problem about setting a different border color for a single textbox (or combobox or listbox) which has focus. How about to change, with a small and fast VBA code avoiding to write code for each textbox, the border color (ora other textbox properties) for a many controls in a form?
I tried using 'For each ctrl in Form....', but I got only bad results. All my control are within differente pages in TAB control.
View 14 Replies
View Related
Aug 1, 2013
I'm relatively new to MS Access (using MS Access 2013 but the db should work on 2010, too) and try to develop a database for an NGO I'm working in. I created almost all the tables (all that I need for now) and made the relationships.
However now I start to create forms and later reports for the actual user. The database will store information about clients and track consultations and assistance the NGO gives to them. There will be around 50.000 to 70.000 clients in the main table. Every client has a specific Individual ID and is member of a family which itself has another specific Group ID.
Now here is my problem: The User usually searches for the respective family by the Group ID. I implemented this with a search query using the ID number of a search text box. All done and no big problem.
But sometimes the ID number is not known so the user needs to search by name (First and Last Name). I use to different textboxes for this and it works in a similar way like the number search by query (Like "*" & [Forms]![frm_SearchIC]![txt_LName] & "*"). All still good However since most of the clients are actually from arabic speaking countries, converting the names into the Latin alphabet is bound to fail and produce a lot of misspellings. Therefore I added 2 more textboxes and 3 comboboxes for the user to give more information about the client and therefore make it easier to search for the person. I was able to produce a query which gives you the right result if you have ALL information at hand. However, this is not always the case.
1) But I cannot find a way to tell the query that if the a certain textbox or combobox is empty, it shall just "ignore" it and use the information at hand. I tried this in the query by adding in the criteria OR .... Is Null. This is alright for one or two textboxes but for the many I have, it seems to be too many different combinations for the criteria. It just worked with some fields but others always had to be filled in...
2) If no information is given at all, the database should inform the user that he needs to enter at least on field. If nothing is found the user should get a msgBox saying "No IC matches your criteria".
3) The results of the searches should be given out in another form where the user can pick the person from 1-to-many results.
I attached a sample database with sample data and reduced tables, fields, and entries ...
View 6 Replies
View Related
May 11, 2014
I have a form with 2 option buttons on it one with year 12 on it and one with year 13. I have a simple form with drop down menus and text boxes allocated for year 12s and 13s. I want all of the year 13 text boxes and drop down lists to be locked if year 12 is selected and I want all of the year 12 text boxes and drop down lists to be locked if year 13 is selected. I do not want to over complicate the form by hiding parts of it or having a new form open depending on the option button selected.
View 9 Replies
View Related
Aug 24, 2013
I have a form with 7 types of weights (7 textbox rows) showing 7 weights in kgs and the others in lbs.When the user update any weight-kgs textbox, the opposite weight-lbs textbox will be updated automatically, and viceversa.Now, I'd like a fast way to code this action without writing the After Update_event for every textbox (they're 14).I have already setup textbox tags differently with "WeightKGS" and "WeightLBS", thinking about using "for each ... next" statement, but I have some problems to resolve what I want.
View 4 Replies
View Related
Aug 21, 2014
I have a form that has four textboxes, date dropdown box and a date box. I am trying to get the form to do the following: Block user from writing in the textboxes if they have not selected a date in the date box.
Get the datebox to look at the behide screens records to see if there has already been a documented date (duplicate date) and inform the user that this date has already been used. Then auto them to the date dropdown.
View 2 Replies
View Related
Jul 9, 2013
I have a form with two textboxes that get their values from two different queries that counts records from table. If textbox1.value equals texbox2.value the textbox2.value back ground colour is green. If they are not equal textbox2.value goes red. Itried with using conditional formatting, but it doesn't work all the time as the form is not updating when it is opened.
View 4 Replies
View Related
Jan 19, 2006
Hello People,
Can you do a dlookup in a query?
View 8 Replies
View Related
Apr 11, 2013
New to the navigation form: I need several forms in the navigation form to all relate to the same client ID field. I have this information on the main form but the form with in the navigation form will not pick it up.
I have tried =[Forms]![Frm Client Information Navigation Panel]![ClientID] But just cant get it to pick up that information...
I would like to have something like the master link fields and, child link fields but when I add a form to the navigation form this option in not available.
View 1 Replies
View Related
Aug 6, 2013
I have two tables
Criteria_Ratings:
FFMin
FFMax
Rating
BaseData:
FF/M
What I am trying to do with a Dlookup is return the Rating when FF/M is between FFMin and FFMax. All fields are Numbers.
FFRating: DLookUp("Rating","Criteria_Ratings",[FFmin]<[FF/M] And [FFmax]>=[FF/M])
View 4 Replies
View Related
Feb 21, 2015
i have an access table.i m using Dlookup function for select data in dlookup , i want to sel field as combo box value, and i want when i change combobox value by select from list ,dlookup result will be change .
how can i do it.
View 3 Replies
View Related
Jun 1, 2015
I am trying to use a Like statement in a VBA dlookup, as some of the fields in a third party db i cannot manage are variations of fields in a table i need.
I currently have:
Me.Clinic.Value = DLookup("[ID]", "dbo_Clinics", "[Name] = Like '%' & [Forms]![frmHome]![subaTcTools].[Form]![subbDST].[Form]![txtClinic] & '%'")
But I get a runtime error 3075 missing operator.
View 3 Replies
View Related