I have a form that has unbound text box controls. The user enters numeric data in each of these text box controls. I want to be able to store the values that the user enters for future use. I am using the following code which was provided on Richard Killey’s web site.
The problem is that the values that the code stores in the unbound text boxes is populated back as text values rather than numeric values.
Here is the code that saves the values.
Code:Private Sub cmdSave_Click() '--- only process Save if there is data in scheme name If IsNull(txtScheme) Then MsgBox "Please Enter A Scheme Name" txtScheme.SetFocus Exit Sub End If Dim rst As Recordset '--- use the primary key (which is always an autonumber field) to find the record '--- if it is a new record, this will find no records, as txtID will be 0 Set rst = CurrentDb.OpenRecordset("select * from tblschemes where ID=" & txtID) If chkNew = True Then '--- do we add a new record and save an existing one rst.AddNew Else rst.Edit End If '--- transfer data from text boxes to table fields rst!MVol = txtMVol rst!TVol = txtTVol rst!WVol = txtWVol rst!ThVol = txtThVol rst!FVol = txtFVol rst!SVol = txtSVol rst!SuVol = txtSuVol rst!Scheme = txtScheme rst.Update '--- save the record rst.Close '--- close the recordset Set rst = Nothing '--- reclaim the memory the recordset was using chkNew = False '--- reset the new flag '--- enable the list box and the Add New button and the Close button '--- must be done before moving focus to the list box lstData.Enabled = True cmdAddNew.Enabled = True '--- make sure the newest data is in the list box lstData.Requery '--- set the focus to the list box lstData.SetFocus lstData = lstData.ItemData(0) Call lstData_AfterUpdate '--- disable the text boxes and the Save button, and make Edit button enabled txtMVol.Enabled = False txtTVol.Enabled = False txtWVol.Enabled = False txtThVol.Enabled = False txtFVol.Enabled = False txtSVol.Enabled = False txtSuVol.Enabled = False txtScheme.Enabled = False cmdSave.Enabled = False cmdEdit.Enabled = True End Sub
And here is the code that populates the values back into the unbound text boxes after an update.
Code:Private Sub lstData_AfterUpdate() '--- whenever a new item is chosen in the list box, display the data in text boxes txtScheme = lstData.Column(1) txtMVol = lstData.Column(2) txtTVol = lstData.Column(3) txtWVol = lstData.Column(4) txtThVol = lstData.Column(5) txtFVol = lstData.Column(6) txtSVol = lstData.Column(7) txtSuVol = lstData.Column(8) txtID = lstData.Column(0) '--- primary key is in the first column (always) End Sub
How do I change the code so it stores the values as numeric rather than text ?
Thank you for any help that can be offered.
i have a form (A) with some unbound combo boxes which generate a subform (continuous) recordsource and the records output
after i filter the subform, i click on a subform record and open another form (B), and close form (A)
i do a bit of editing on form (B), then i click a button to go back to form (A).
is it possible to open the form (A), with the unbound combo boxes values at the same value as when form (A) was last closed, and as such the subform records output as per when the parent form (a) closed
if this is possible i can then have a button on form (B), to go to the next or previous record on the form (A) subform
apologies if this sounds confusing, many thanks in advance
I am having a problem with calculated fields that are populated on the main form from the subform not saving to the table the main form is linked to.
I created a Purchase Order table that has information on what emplyee created the record, reason for order, customer information if its ordered for a customer, creation date, eta date and notes while the Purchase Order details table is for information on the supplier, product item number, product name, quantity and cost. they are linked by the Purchase Order number which is the primary key in the Purchase order table. it all looked good so i made the form with the Purchase Order Detail as the subform, i got the form all working great and how i wanted it but then i decided i wanted the supplier name and the subtotal of the cost in the main form populated or calculated by the values in the subform.
I copied the fields i wanted populated in the main form to the subform footer and added the calculation for the subtotal then added the formula to the source code on those fields in the main form so the values would populate. it all worked great on the form and the values populated as they were supposed to so i saved the record and went to look at the tables and i found that while the values in the calculated fields that I populated from the subform showed up in the form they didnt save to the table while the non calculated fields saved fine. i did some experimenting and found that if i delete the code and put the data source back to the table in the form and just type something in the text box it would save to the table but not if i had the code in and let it populate.
an example of one of the codes i used to populate the data in the main form is:
I have an unbound form in which a user enters data relating to a credit dispute, and when they hit the Save button I have a sub that is intended to insert that data into a table. This is a bit out of my comfort zone, so I found some code from another forum and adjusted it to my needs. However, I'm getting errors.
The table name is tbl_complaints. The fields from the form are:
Private Sub cmdSave_Click() Dim StrSql As String On Error GoTo ErrorHandler StrSql = "INSERT INTO tbl_complaints " _ & "(ACCT_NUMBER, CLIENT_NAME, EOSCAR_TYPE, EOSCAR_CONTROL_NUMBER, METHOD_OF_RECEIPT,
[Code] ....
The error I get is error number 3075, and it says I'm missing an operator in the section that references cboResponseType, but I can't seem to figure out what I'm missing. My head is spinning from staring at these parentheses and apostrophes for so long.
I want to have a box with yes/no choices defining the Lessons a Student chooses. Sth like this Because the Lessons are quite plenty and they change from time to time, I don't want to have them predefined in the Sudent table, but to have a related table containg the Lessons providing more flexibility. My problem is how to assign the Yes/No values from the form to a single record. ANy suggestions? A first thought is to create a List from Lessons table, with 2 columns. 1st the Lesson and 2nd the Y/N box. Every Lesson would have a value like this: 1,2,4,8,16,32,64... With this way the sum of the Lessons would be unique for each combination and it could be saved in a single record. But such a solution is not so practical. Any alternatives?
I have an unbound text box. I put a value, run an append query and append the value to the table. I want to know if I can delete the value in the text box automatically when the append query excutes. I am using a macro to run the append query.
I have a Form - "Cases". The button to open the report is on that form as are the values I want in the report.
I want to pull the value of Case Name and Case Number from the current form view and put them together in the single field on my report.
I can "almost" do it. Then VBA gives me a warning - it says that you can't assign a value to the control on my report.
Can anyone give me any ideas?
by the way: I chose to make this an unbound report because I'm using SQL server as my back-end and my Access is an .adp file. SQL (so I was told by the programmers at work) can't pull in variable criteria from a form like Access Queries can. So this all has to be put in VBA.
I am working on a timesheet application which allows users to insert multiple timesheet entries in a grid style format. the first row is visible and to add another row users click on a command button which makes the next row of fields available and ready to fill in and so on and so forth. I need the fields to be unbound and then when the user clicks on a save button for example then it inserts those values into the relevant table. Table name is tbltimesheet, field names are id, companyname, project, activitydate, activityhours, activitynotes, username, userid
I have a report that selects and shows records where a specified date field is within the range of 2 dates that the user enters.I created 2 unbound textboxes on the report with a Shortdate format and InputMask 0000-00-00;0;_.When user enter correct dates, then everything works fine: selection is properly done, the right records show up.But I have 2 problems:
1-the input mask is not working: the user can input anything! 2-the 2 unbound textboxes do not show the dates entered by the user.
It seems the value entered bu user does not go straight into the unbound textbox. How do I either intercept the value entered by the user directly into the unbound textbox or via a variable?
I am trying to find a way to allow the user to enter multiple numbers in an unbound box that I will pass to a query as parameters. I already have it set up to pas the parameters from the form but if i try to do more than one number it doesn't work.
I have tried:
1306 or 1307 or 1308 1306, 1307, 1308 "1306 or 1307 or 1308"
I was reading somewhere that when the value is picked up from the form it is not like you are typing it right in the criteria box of the query.
So are there any other options here? Is there a way to enter all the number in a box and then use vba to create an array and then pass that to the query?
I know that it isnt advised to store the concatenated value but in this case, I have a memo field which is the description of a particular system component.
i have Unbound Combo Boxes for descriptive elements such as COLOUR, SIZE, CONNECTIVITY, MAKE.
ALL of these i would to store in a field in my table and called Description and separate them by colons or the actual words which describe the category.
I am trying to open a form in design mode and add controls, this i have done. I am doing this all in a class, and am having trouble saving the modified form.
I have tried using the following, both produce errors
I have a timer form which closes the database after a period of time with DoCmd.Quit. Another form is open at this point but if a user has left it in the middle of editing it I want to be able to save the record in the other form and close it before the timer form closes the database.
What VBA do I need in the timer form to save the record and close the other form before DoCmd.Quit? Just to be clear the code is...
Private Sub Form_Timer() On Error Resume Next Me.Tag = Val(Me.Tag) - (Me.TimerInterval / 1000) Me.Caption = "The database will exit in " & Me.Tag & " seconds" If Val(Me.Tag) <= 0 Then
I have a onclick tied to a label (for decoration purposes) that when clicked it launches VBA that essentially updates a form. All that part works except it will not recognize any changed value of the field I was last in?
Just to try to explain best as I can what happens.
- Form gets opened - I change field (quantity field) - I click the Label - It reverts to pre-existing value.
if I click off of the text field first then do the onclick - it recognizes just fine.
Is there a simple way to make sure all fields on a form are filled before the data is saved to the table? I looked into using thew IF is Null Then but for 30 fields that is alot of code. Does anyone know a easier way?
Hello, I have a form and I have a button so people can open records to load into the form. The problem is that whenever they close the form it updates the information in the table. How do I stop that from happening? I want the information in the table to update only when they hit the button I made (which works).
And how do I stop it from loading the record when I open the form, or maybe I can specify to load a blank record instead, how do I do that?
I would like to have one stupid question, because I could not find any answer on this forum. I want save the Form as Report. I can do that from "Menu bar", but I want to do that from the code (VBA or Macro) without inputting the output parameters by users. Do you have any idea how?
Hi I have created a form which I would like to save, and use as my own template. This is because the form is linked, and when I try to make any structural changes to the database, I have to delete the link, start again, and then redesign the form. Is there anyway I can save the form, to use again, instead of starting from scratch? Thanks so much! Hayley
Got a quick question, is there a way to have a field in a subform update a field on the primary form's table? In other words, enter the data once and it stores it twice, on the subform table and the primary form table.
On my Form I have a Label (Recnote) which gets changed by the VB code if criterior is true. My form does change this correctly however, once I quit (or close the Form) and come back, the changes dissappear.
But the strange thing is that every now and then it does save it.
Any ideas??? Any other command I should use?
The following works as it disables my Import button and changes the Label contents but does not save when exited
Private Sub CloseME_Click() DoCmd.Requery
If [CountOfOracle Co] = 0 Then MsgBox "Cannot Close ME Yet", vbOKOnly, "Circular Rec" Else
Me.Recnote.BackColor = 65535 Me.Recnote.Caption = "Final Reconciliation" Me.Recnote.ForeColor = 32768 Me.Import.Enabled = False DoCmd.RepaintObject DoCmd.Save End If
I was just wondering if it's possible to save a form with all its settings and selections, and reload it later? So if a user is filling a form out with a few subforms which show a yes/no field in datasheet view, if they select a few options in the yes/no field and hit save, when they reload, it will bring up the form with everything they had selected when they hit save. I'd like to put Save and Load buttons on my form if it's possible.
I have a simple form with a save button created directly from a table. I would like the on click event to check 4 fields to be sure that they weren't left blank and have a msgbox prompting to fill in the missing data, obviously not saving until all fields are complete. Fields are FirstName LastName Age Position. If all data is filled I would like the button to save the record and begin new record.
Help!! I have a form created on a query. I created a field to add up the cost of all components on the form and now I need to save it to a field in a table so that I can run a report (my invoice)! Any suggestions??