I have a form that contains a textbox and a listbox. The listboxs rowsource is tblSPNZ.
The table has 2 fields 1 is and autonumber and the other is where I want the results to go.
How do I make a command button populate the table? Avoiding putting any results into the autonumber field?
It's an unusual request, I know, but it's necessary for my purpose.
I have a form, frmMain that I use to update a number of tables. On it is a number of combo boxs, comProduct, comBrand, comSize, comPrice and comQuantity. comProduct opens a new form, frmNew if the users input is not already in the table. On frmNew there are again combo boxes comProduct, comBrand and comSize. This form adds the record to the table.
So, if I input a new value - not already in the database - for product in the comProduct combo box, the form frmNew appears and I can proceed to define the product, brand and size of the new record. The form then closes and reopens frmMain and tabs across to comQuantity (skipping the fields I've already defined in frmNew).
Now if you can wrap your head around that, here is the problem: Because I've already entered the values for product, brand and size in frmNew, I want them to automatically appear in the appropriate combo boxs on the frmMain form. I've been using the following code (executed from frmNew, so Me = frmNew):
It works, but I've since discovered it creates a new record in the table so I end up with two duplicate records (one when I submit frmNew and another when the values are automatically input into frmMain.)
Now, my question: How can I display these values in frmMain without having them create the second record? I was thinking of using a SELECT query somehow, but I don't know where to begin. I also considered using labels instead of comb boxes, but I'll need to be able to edit them if the record already exists.
I am at work, and I have acquired a database that prints labels. They now want the database to be coded so that after certain labels are printed the database will print a blank label. I have the code figured out as a Do While statement in order to print the blank label. The problem I am having is that I am trying to use the Insert Into command to insert the filepath into the table that adds the blank label.
|DoCmd.RunSQL "INSERT INTO Rod_tmakLabels ( Print, [Order] ) SELECT Yes AS Expr1, 'Rods Labels' AS Expr2"|
If I run the above command, it just adds the text "Rods Labels" at the end of the table. Is there anyway with the INSERT INTO command that I can insert the new label between the 2nd and 3rd row and add another row? Or is the command designed only to add a new row to the end? I haven't had any luck searching for this yet.
I have a form that has several fields that a user will enter data. When finished, the data is inserted into a table. Works great. What I want to do now is look at one of the fields entered and if it is equal to a certain value, I want to disable one of the other text boxes (fields) on the form AND pop a screen that will allow the user to enter a list of names that will update a different table.
So, if user inputs a directory name GENERIC, the txtScriptName box needs to be disabled/greyed-out and I need a form to pop so the user can put in a list of script names. If any other directory name is entered, the txtScriptName box needs to remain editable. (For directories equal to GENERIC, there will be multiple script names instead of just one)
I've been successful at getting the form to pop if GENERIC is entered but can't figure out how to grey-out the txtScriptName field. I tried using Me.txtScriptName Locked in the Before Update of the preceding field but it didn't work - could still update the txtScriptName field.
I'm trying to make a report query work but with no succes so far. Can anyone please help me? I've got a multiselect listbox and a txtbox (txtCursisten) where the results from the multiselect listbox appear. I want to get the results out of a table (tblAbsentie) where I can set a start and end date AND use the people selected in the txtBox. So far I've got a NOT working query, a report based on the query and a button on my form.
The VB code behind the "show report" button is this:
Private Sub cmdAbsentiePerCursistPerPeriode_Click()
On Error GoTo Err_cmdAbsentiePerCursistPerPeriode_Click
Dim db As Database Dim Q As QueryDef Dim sql As String
If IsNull("Me.txtCursisten") Or Me.txtCursisten = "" Then Exit Sub Else
Set db = currentdb() Set Q = db.QueryDefs("qryAbsentiePerCursistPerPeriode") Q.sql = "SELECT tblCursist.Naam, tblAbsentie.Datum, tblAbsentie.Lesuur, tblAbsentie.AantalLesuren, tblAbsentie.Deelkwalificatie, tblAbsentie.Docent, tblAbsentie.Gemotiveerd, tblAbsentie.Reden, tblAbsentie.Status, qryCountLesuren.SumOfAantalLesuren" & _ "FROM (tblCursist INNER JOIN qryCountLesuren ON tblCursist.OVnr=qryCountLesuren.OVnr) INNER JOIN tblAbsentie ON tblCursist.OVnr=tblAbsentie.OVnr" & _ "WHERE (((tblAbsentie.Datum) Between [Voer begindatum in] And [Voer einddatum in]) AND ((tblAbsentie.OVnr) In ("Me!txtCursisten"))); " Q.Close
DoCmd.OpenReport "rptAbsentiePerCursistPerPeriode", acPreview End If
On Error GoTo 0 Exit Sub
Exit_cmdAbsentiePerCursistPerPeriode_Click: Exit Sub
Err_cmdAbsentiePerCursistPerPeriode_Click: MsgBox "Selecteer klas en cursist(en)." Resume Exit_cmdAbsentiePerCursistPerPeriode_Click
End Sub
I get a syntax error when pressing the button. Please help... SeBasTiaan
I have a form, on the form a textbox. Through the expression builder I have assigned one value to the control source of that textbox from a query. The query holds three values, all three of which I would like to use in a separate textbox. When I open the form the textbox just displays #Name. I'm guessing since nothing is happening because the query isn't run by command yet. I've used code like this:
Private Sub AppointmentID_Click() Forms![ClientsMain]![TechViewSummarySubForm].Form.Requery Forms![ClientsMain]![TechViewSummarySubForm].Form.Refresh End Sub
to get a query to open, run etc. But that one is located in a subform which has the query as a control source. How does that work in the case I have now? Can I use the DoCmd function to run the query and get a value from it for the specific textbox? Or can't I use a (segment of a) query as the controlsource of a textbox at all?
I'm asking this since now I calculate and store certain totals by use of a textbox with =Sum() as control source in the footer of a form, which values I then assign to some fields in a table.
But I would also like to learn the right way, using queries, maybe for a later version of my DB when my skills have improved. I've been struggling with this now for a bit, but without succes. So that's why I wonder if I can assign a query or more specific one value of a couple of values in a query to a textbox in a form which has a totally different control source itself.
Hi all, I have a select query that pulls in two date values from a textbox on a form.
SELECT DISTINCT Table01.SRV_NAME, Table01.IMP_CUTOFF_DT FROM Table02 INNER JOIN Table01 ON Table02.Servicer = Table01.SRV_NAME WHERE (((Table01.IMP_CUTOFF_DT)=[forms]![frmreport].[txtsqldate].[value])) ORDER BY Table01.SRV_NAME;
However when I run it I get the following error message:"This expression is typed incorrectly, or it is too complex to be evaluated. For example, a numeric expression may...." but when I copy and paste the value of that txbox from the form into the query it works fine.
Can anyone see where the problem lies? I can't work it out.
Here's a bit of a pickle I've been trying to wrap my noodle around.
Anyone have an idea what route to pursue (unbound form, or afterupdate, etc?) to force a validation rule on the number of characters in a text box based on the value of combobox in the same form.
Example: If cboBox1 = 840, then len(txtBox2) = 6 But if cboBox1 = 820, then len(txtBox2) = 3 And so forth?
I have placed a txtbox on my form and via a cmdbutton a can copy data to another text box. Is there a way I can replace data? Will appreciate any help.
I have a form that has a combobox and a field text. If i select any value in combobox i want to update the txtBox but not with the ID of the selection. I need to get the description of the combobox selection which is essentially the Column 2.
I have a table tblDateGroups, with two field, [Group] (like This Week, Next Week, Last Month, etc) and [Code] that holds the code for criteria for each group in a query. I know the code is fine (like next week = Between Date()-Weekday(Date())+8 and Date()-Weekday(Date())+14 ) because I tested before putting in the table.
On my form I have a combo box that list all the [Group] and i hidden textbox that looks up the code based on the cbx after update...all that is good.
However, when i try to requery the report the criteria is not working. I am simply using the date criteria to read the hidden text box with the code string.
the error code is "This expression is typed incorrectly, or it is too complex to be evaluated. For example, a numeric expression may contain too many complicated elements. Try simplifying the expression by assigning parts of the expression to variables."
The 3rd LB value chooses a field. The Fieldname Table has field "Field Type"
I want to change the Text box next to the List box to this entry in the Db.
Ie. If I choose a field in the LB, say "Done?", then to update that field it needs to offer me a "yes/no" field type Therefore it changes the TextBox to a Checkbox (or combo with Yes and No as options)
I would like to write an expression (i presume) to auto fill a text box based on the selection made from a combobox...can anyone help or point me to a tutorial that deals with this??
If you want to use a "DoCmd.RunSQL "INSERT INTO" command to insert data in a table and the data to insert comes from a table and a form, could this be done in one pass?
So...writing a record wit 4 values from table1 together with a additional value from a textbox in table2 as 5 values.
I have a parent table (tblLabels) and a child table (tblRevision) where the revision history for the parent table is kept.
The parent table is populated via an excel import and may have several records imported at once. Instead of having the user manually enter a new record note in the child table for each record imported into the parent table, I've created a form that collects the necessary data (date, person who added the record, person who authorized the record, and notes) and then creates a revision history for each new record.
This is what I have so far:
Code:
Private Sub cmdAddNotes_Click() Dim strSQL As String Dim RevisionDate As String Dim RevisionRevisedBy As String Dim RevisionDesc As String
[Code] ....
When I run the code nothing happens. No error, no new records create, etc. My suspicion is that I may need to use an INSERT INTO query instead of an UPDATE query, but I'm not sure how to go about matching up the foreign keys if that's the case.
I have a small database with 4 tables that I am using for the current problem. The tables are call, parents, mailman, orders. Call and parents are related by the call ID (a primary key in the Call table.). Mailman and orders are related by a Unique Id (a primary key in the mailman table.).
Forms involved are frmmain and frmsub.
Frmmain contains the call table information in the main form and parents information in the subform.
When a user enters a call with call ID and enters the operator name and parents information in the sub form, When a user clicks the OK button on the main form, necessary changes should take place if they enter the case type in the sub form part of parent information as ‘missing information’ or ‘missing link’ then the parent information with fields first name, lastname, case type, operator information should be inserted into mailman table in appropriate fields.
Simultaneously a record should be inserted into orders( after the record is first inserted into mailman, since both tables are linked with unique id) with the following information. Orderid being autonumber. Uniqueid from the mailman table. Orderdate system date. Ordertype should be “Mailman”
How to copy a column from one table and insert it into another table in the same database
Hi, All,
I have two tables (old and new) sitting in the same database. The new table is the result of 'data cleansing' done by an external company. In the process (export and import via excel) two memo type colums in the table were truncated in excel.
To make the new table usable, I must therefore now copy/insert the two memo columns from the old table into the new table.
Both tables are already Access tables and sit in the same database. Both tables, of course, have the same number of rows.
I tried to high-light one column in the old table, clicked copy, then high-lighted a blank column in the target table, then clicked Paste, but got error msg: "This text is too long for this field. Try copying a shorter text", as if I had wanted to copy the whole column into one cell rather than one column into another column of equal length.
Newbie question: I have a database where we track dispatched with two tables, one called Slots, the other called Dispatches. In the slots table there are 2 fields, one called Week (which hold the Monday date for each week in the year), the other called Available (in this field we want to manually enter a number that will tell the system how many dispatches we can do that week). We want to automatically take the number from the Slots.Available and enter X number of blank records in the Dispatch table with the monday date. How can this be done? Then we will create a form that can be filled in with the balance of the information. Thanks
On the creation of a reconrd in the main table I'm trying to auto fill a sub table with standard information for the user. This is what I'm using to insert into the sub table:
I have an access database that contain 2 tables and 1 form :
table1 named customers (custid-custname) table2 named sales(salesid-custid) form named form1 contain (salesid-custid) *note:in form1 custid is combobox
What i need is when i select an customer from combobox the column custid in sales table get custid not custname
I use this sql statement to get combobox items from customers table
Hello, I have a table with 2 fields - WeekID(autonumber) and WDATE(date/time). What I want to be able to do is to enter a value for the first date and then have the next 25 entries automatically entered. Each entry is to be 1 week greater than the previous entry. Ultimately giving me a list of dates, numbered 1-26, incremented weekly. I assume the DATEADD function is to be used but i cannot determine how. Any help / pointers is greatly appreciated. Thanks
Hi I am creating an employee db, with fields including employeeID, surname, firstname, partnerSurname, partnerFirstname, partnerID. As some partners work at the company, I want the partnerID to list (thorugh a value box) employeeID's that match surname to a partnerSurname and firstname to partnerFirstname. Is this possible? Any help greatly appreciated. Thanks in advance.
Insert into tableA (x,y,z) = (SELECT x,y,z FROM tableB) WHERE NOT EXISTS (select x,y FROM tableA,tableB WHERE tableA.x = tableB.x AND tableA.y = tableB.y)
Basically I want to insert data in tableA from tableB if it does not exist in tableA yet.