Unbound Form Problem

Oct 15, 2006

Hi
I am using an unbound form for data entry to prevent errors getting into the table i.e. if with a form bound to the table, the user exits the form having only entered one field, a record is created with that field completed only.
I use code to write the record to the table but unless the form is closed and reopened any subsequent records are not added to the table. I am probably going about this in completely the wrong way and any advice would be appreciated. Below is the code that I use.

Keith

Private Sub cmdSave_Click()
On Error GoTo Err_cmdSave_Click

'Validate Data before Save
If IsNull(Me.txtRegNo) Or Me.txtRegNo = "" Then
Call MsgBox("Registration Number is Required", vbInformation, "SAVE ERROR")

Me.txtRegNo.SetFocus
Exit Sub
End If

'Save DATA
Dim SQL As String

SQL = "INSERT INTO tblVehicle(RegistrationNo,VehicleMake,EngineMake,S eats,ChassisNo,DateRegistered,
PurchaseMileage,PurchaseDate,LicenceRenewalDate,Te stDue)" &
"VALUES('" & [txtRegNo].Value & "','" & [txtVehicleMake].Value & "','" & [txtEngineMake].Value & "','" & [txtSeats].Value & "','" &[txtChassisNo].Value & "','" & [txtDateRegistered].Value & "','" & [txtPurchaseMileage].Value & "','" & [txtPurchaseDate].Value & "','" & [txtLicRenDate].Value & "','" & [txtTestDue].Value & "')" '"

DoCmd.SetWarnings False

DoCmd.RunSQL (SQL)

DoCmd.SetWarnings True

'Reset Form
Me.txtRegNo = ""
Me.txtPurchaseMileage = ""
Me.txtVehicleMake = ""
Me.txtEngineMake = ""
Me.txtChassisNo = ""
Me.txtDateRegistered = ""
Me.txtPurchaseDate = ""
Me.txtSeats = ""
Me.txtLicRenDate = ""
Me.txtTestDue = ""
Me.txtRegNo.SetFocus


DoCmd.Close
DoCmd.OpenForm "frmVehicle"

Exit_cmdSave_Click:
Exit Sub

Err_cmdSave_Click:
MsgBox Err.Description
Resume Exit_cmdSave_Click

View Replies


ADVERTISEMENT

Modules & VBA :: Unbound Form - Selecting Label OnClick Does Not Recognize Changed Form Field?

Feb 5, 2015

Access 2007
Unbound Form

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.

View 7 Replies View Related

UnBound Form

May 25, 2005

I didnt write here alot of time,

so my english became less.

here is my question

I have an unbound form
In the form there are 40 textboxes.

There names are like this:
A1
A2
A3
A4…

When I open the form I wrote code like this:

For I = 1 to 40

If …. Then
*****************
I WANT TO WRITE IN THE TEXTBOX
BUT I DON’T KNOW WHAT IS THE “I” VALUE
IF I WROTE “A” & i
ITS DOSENT WORK
WHAT CAN I DO?
******************
End if

next

thanks!

View 2 Replies View Related

Unbound Form

Mar 16, 2006

Hello Learned Friends,

I have an unbound form with start date and end date text boxes. The code behind the form allows a combination of dates to produce a report, but only one named report. I would like, with your help, to give the user a choice of reports to preview and/or print. Thank you in advance for divulging your knowledge.

View 14 Replies View Related

Unbound Form

Sep 21, 2004

I am trying to save data from an unbound form to a table based on "VBAUnbound.zip" posted by sbaxter.

The Code looks like this:
Code:Private Sub cmd_ip_save_Click()'Error Handling On Error GoTo cmd_ip_save_Click_Err' Declare Variables Dim DAOdb As database Dim DAOrs As DAO.Recordset' Update Database Set DAOdb = CurrentDb t = "M_Paint" Set DAOrs = db.OpenRecordset(t) With DAOrs .AddNew .Fields("Catalogue_Code") = Me.txb_ip_cataloguecode .Fields("Base_Metal") = Me.cmb_ip_basemetal .Fields("Paint_Type") = Me.cmb_ip_painttype .Fields("Color_Family") = Me.cmb_ip_colorfamily .Fields("Metallic") = Me.cbx_ip_metallic .Fields("Surface_Quality") = Me.cmb_ip_surfacequality .Fields("Number_of_Coats") = Me.txb_ip_numberofcoats .Fields("Supplier") = Me.txb_ip_supplier .Fields("Product_Name") = Me.txb_ip_productname .Fields("Color_Name") = Me.txb_ip_colorname .Fields("Color_Number") = Me.txb_ip_colornumber .Fields("Top_Coat") = Me.txb_ip_topcoat .Fields("Pre_Finish_I") = Me.txb_ip_prefinish1 .Fields("Pre_Finish_II") = Me.txb_ip_prefinish2 .Fields("Finish_Comments") = Me.txb_ip_finishcomments .Fields("Size") = Me.txb_ip_size .Fields("Number_of_Samples") = Me.txb_ip_numberofsamples .Fields("Compilation") = Me.cbx_ip_compilation .Fields("Location") = Me.txb_ip_location .Fields("Date_Received") = Me.txb_ip_datereceived .Update End With' Message box MsgBox Me.txb_ip_cataloguecode & " Added" DAOrs.Close DAOdb.Close' Exitcmd_ip_save_Click_Exit: Exit Sub ' Error notificationcmd_ip_save_Click_Err: MsgBox "An unexpected error hass occurred." _ & vbCrLf & "Procedure: cmd_ip_save_Click" _ & vbCrLf & "Error Number: " & Err.Number _ & vbCrLf & "Error Description:" & Err.Description _ , vbCritical, "Error" Resume cmd_ip_save_Click_ExitEnd Sub

I am getting an error "Runtime Error '424' Object required" at this line:
Set DAOrs = db.OpenRecordset(t)

When I hover my mouse over "DAOrs" it flags a messages saying "DAOrs = Nothing".

What does that mean? Can anyone help??

View 4 Replies View Related

Increment A Value In An Unbound Form

Feb 3, 2005

Hi Everyone,

I will do my best to try and explain what I am trying to accomplish.

I have a form that has two fields [NumbX] and [NumbY]
They way they display on my form is [Numbx] of [NumbY]. These two field show which transaction of the total number of transactions. So basically if someone comes in to do a transaction, they could be doing just one ([NumbX =1] and [NumbY] =1). If they are doing 3 transactions the fields would be [NumbX]=1 and [NumbY]=3. As they complete subsequent transactions [NumbX] increased incrementally, until X =Y.

Every transaction ends with a Print Form opening and the user confirming the printing of the transaction. In the print form I have coded it to clear the main form once X= Y otherwise retain some of the information input in some of the fields for the subsequent transactions. Right now, I have it set up that the user inputs [NumbX] manually. What I would like to do is have that automatically increase by 1 when the print form closes. This should continue until [NumbX]=[NumbY].

The fields are unbound and used solely for driving other activity (opening other forms) so autonumber is not an option.

Any suggestions??

Thanks

View 3 Replies View Related

Unbound Text Box On Form

Aug 30, 2005

I am trying to troubleshoot a form and I am at wits end with it. :eek: I hope someone can help me.

There is a form whose record source is based on a query. When it opens it loads all the records. At the bottom of the form, there is an unbound text box that is used as a filter. The person is suppose to be able to type something in there and then once the cmd button is pressed it filters bases on the value of that text box. That appears to work fine.

The problem is, when the form loads, the unbound text box is locked. It does not allow anyone to type in it.

I checked form properties and also the text box property and it is not locked. I have added code on the getFocus, OnLoad, OnUpdate..ect, to make the properties of that text box unlock it self. I have had no success with that.

I did notice that after the form loads and I hit Design view and then change back to Form view, the text box is unlocked and allows typing. :confused:

Why then does it allow editing, but not on initial load. Any help would be wonderful. If further explanation is necessary, please ask.


Thank you

View 4 Replies View Related

Clear Unbound Form

Jan 29, 2006

Hello all,

Need your help again.

I have an unbound form with text boxes and 1 check box.

I created a module named Reset;

Private Sub Reset()


[Sales].Value = ""
[Corporate].Value = ""
[EndDate].Value = ""


End Sub

1) I linked this module to a macro so that on clicking a button, the macro runs the module and closes it, but it's not working.
in my macro, I have open module: Reset
I also have clode module= Object: Module, Name: Reset
But this is not working

2) Also, how do I clear the check box?

Thanks again for the help.

View 6 Replies View Related

Recall - Unbound Form

Dec 5, 2004

I've been looking at Sbaxters example unbound form. I want the form to be unbound, but I also need the form to show the autonumber straight away when they create a new record, but the data they enter into the text boxes only gets written to the DB tables when they hit the Save button. Is this possible?

Also, on my forms I always have a record count (on the On_Current event) of the form. When they use the next button this changes to show 1 of 100 for example. If the form is unbound how do I get this to display how many records are in the DB or how many records have been found during a search.

Cheers in advance,

Recall.

View 1 Replies View Related

Continuous Form With Unbound Check Box?

Jul 7, 2005

hi guys, i have a continuous form with a check box and a button on each record's row.

now if i dont bind the check box to a control source when you tick it, it gets ticked for each record, i am using the tick box to pass a state to the button ( uses an if statement ) so that it will done different things if it is ticked when the button is pressed.

can anyone help me to get this to work without having to bind the check box to a control source?

best regards

View 3 Replies View Related

Unbound Data Entry Form

Aug 14, 2005

Is anyone there who can show me a db sample of unbound data entry form. I want to control the builtin auto save of Access, because sometimes I don't want to save the data of my form..

Thanks,
cagay

View 12 Replies View Related

Adding Records To An Unbound Form

Sep 2, 2005

Hello, here is my problem:
I have a form to add records to my table. I cant bound it, because the controls are tick boxes, and they need to be "converted" into text to add them to my table.
I have a save button, so I can execute an insert statement with all the data I want to add to the table.
The problem is, once I have saved the record, I want to clear the form to add a new record, and I cannot use a docmd.gotorecord acnext as it is an unbound form.
Is there any way to clean a form without going control by control?
Thanks!
Cristina

View 1 Replies View Related

Friggin Combobox Unbound Form

Dec 14, 2005

I would like to have a form with a combo box open and then when a company is clicked on i would like for my report to open showng all those listings. I have the query and the report and the form but how do i get them to all work together they are not playing nice.

View 12 Replies View Related

Button That Displays A Form In Unbound Box

Sep 7, 2006

Hi

I've checked out some nice solutions on this forums but i'ts not really what I want and I've tried to modify them but without success.

Can anyone create a sample or let me know how to do this the easiest way preferably with no scripts (or small ones)

//Mikael

View 1 Replies View Related

Tabular Form With Unbound Control

Nov 23, 2006

Hi,

Is it possible to have an unbound image control on a tabular form displaying a different image for each record ?

Actually i have tried putting some code on the onCurrent event, but it is displaying the same image in all records, depending on which record is current.

This is the code which i tried using:


Private Sub Form_Current()
On Error GoTo Err_Form_Current
If Not IsNull(Me.txtCountry) And Not IsNull(Me.txtCatalogueNumber) Then
Me.Stamp.Picture = Environ("userprofile") & "My DocumentsDatabasesPhilatelyStamps" & Me.txtCountry & Me.txtCatalogueNumber & ".jpg"
ElseIf IsNull(Me.txtCountry) Or IsNull(Me.txtCatalogueNumber) Then
Me.Stamp.Picture = Environ("userprofile") & "My DocumentsDatabasesPhilatelyStampsNotAvailable. jpg"
End If
Exit_Err_Form_Current:
Exit Sub
Err_Form_Current:
If Err.Number = 2220 Then
Me.Stamp.Picture = Environ("userprofile") & "My DocumentsDatabasesPhilatelyStampsNotAvailable. jpg"
Else
MsgBox Err.Description, vbExclamation, "Error #" & Err.Number
End If
End Sub

Actually, the above code works fine for Single Form, but not on tabular form.

Thank you for any advice.

View 2 Replies View Related

Unbound Combo Box Search On Form

Sep 15, 2004

It wont populate the pertinent fields.. where have I gone wrong. DB attached.

View 8 Replies View Related

Can You Populate A Unbound Continious Form

Feb 18, 2005

Can you populate a unbound continuous form. If yes how do I do it

Phil.t

View 8 Replies View Related

Another Unbound Form Question (VBAunbound)

Mar 21, 2005

ok, I've copied/changed some code and get "data type mismatch in criteria expression". Obviously, I don't quite understand what I'm doing. Access 2003.

Code: Private Sub Command13_Click()On Error GoTo Err_Command13_Click Dim DAOdb As DAO.DatabaseDim DAOrs As DAO.RecordsetDim s As String Set DAOdb = CurrentDb()s = "Select * from tblECOs where tblECOs.ECO = '" & ECO & "';"Set DAOrs = DAOdb.OpenRecordset(s)With DAOrs.Edit.Fields("status") = "CANCELED".Fields("date") = Me.txtDate.UpdateEnd WithDAOrs.CloseDAOdb.Close Exit_Command13_Click:Exit SubErr_Command13_Click:MsgBox Err.DescriptionResume Exit_Command13_Click End Sub

Thank you.

View 2 Replies View Related

Updating Unbound Field On Form

Nov 4, 2005

I have a form with a bound combo box. There is an unbound text box for display purposes only that is supposed to reflect the third column of the combo box for the current record.

I set it's default value at [cmbPartyType].[Column](2) .

It works for the first record. but when I scroll through the records, the box keeps the value that was appropriate for the first record. how can I get it to look at that combo box on every form? Even if I am not update records, just looking at them?

View 3 Replies View Related

Linking A Field To A Unbound Form

Oct 16, 2006

i have a form "send mails" which is unbound
it have a combobox field "to" ,i want it to bound to a field "names" in the table "email"

View 5 Replies View Related

Saving Values In An Unbound Form

Aug 24, 2007

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.

View 5 Replies View Related

Forms :: Getting Value From Unbound Textbox Into Form

Jun 20, 2013

I have a unbound text box in the form header and have a command button in form I am wanting to put the unbound textbox value into a bound textbox on form.

View 1 Replies View Related

Unbound - Populate Textbox In Form

Nov 13, 2012

I'm trying to populate a form textbox which is unbound.

I have table with a list of peoples login names and a query filtering these names once a user logs in. If the GetUserName() matches one of the names in the table then user is authorised. this part seems to be working fine. User not on the GetUserName() list the filter says blank ie Not Authorized.

How to take this confirmed user name and place it into a textbox on a form?

Table name: [tblUserNames] with [IngEmpID] & [UserName]

Query Name: [qryUserNames] with a Criteria GetUserName()

View 7 Replies View Related

Navigating Records On Unbound Form With VBA

Jul 1, 2013

I have a form that reads records from a query.. It loads the first record into the form, without issue.

Code:
Sub FormLoaded()
Dim r As DAO.Recordset
Set r = CurrentDb.OpenRecordset("Results") ' Query we want
Forms("frmmainnew").lbladdUser1bad.Visible = False

[Code] ....

Now I have have 2 buttons at the bottom of the form, one for next record and another for previous record...

Code for next record

Sub NextRecordbtn()
Dim r As DAO.Recordset
Set r = CurrentDb.OpenRecordset("Results") ' Query we want
r.MoveNext
If r.EOF = True Then

[Code] ....

I know that I have 3 records that result in the query named "Results", the next record button will bring the form from record 1, to record 2... however it will not move from the 2nd to the 3rd record...

View 14 Replies View Related

Unbound Form And Selection Boxes For Report

Oct 25, 2005

I have set up a query to give me details of employees names, the business they work for and where they work.

If I run it without criteria I get all of my records, as you would expect.

However, I want to be able to select parameters from combo boxes and then run a specific report of employees by location. I did have this working by accident a while ago but have changed quite a lot since then.

I have set up an unbound form with three combo boxes - Business, Business Unit and Location. Then a button for preview and print report linking to my report template.

I have refernced the controls in the relevant columns of my query as: [Forms]![FormName]![Control].

When I run the query I get nothing back and I don't understand why.

View 9 Replies View Related

Open Filtered Form From Unbound Switchboard

Feb 3, 2005

I get the feeling I'm really missing something glaringly obvious here but I'm struggling.....

I have a combo box on my switchboard that looks up field txtOfficer in a query and then want it to open up a new form containing only those records relating to the officer name selectedtxtOfficer

The rowsource for the combo is:

SELECT DISTINCTROW [qryMain].[txtName] FROM [qryMain];

and the on click event is:

DoCmd.OpenForm "frmFiltered", , , "[txtName] = " & Me.cmbOfficer.Column(0), acFormEdit

When I select a name from the combo I get a parameter box and have to type in the name to open up the filtered records form. How can I get rid of it so the selection is one seamless process? :confused:

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved