Keep fields of Form from being populated with first record of table.

loki1049

Registered User.
Local time
Today, 11:32
Joined
Mar 11, 2010
Messages
28
I have a form which that is bound to 1 particular table, whereby people can enter data into the text boxes, and select data from the drop down menus, and then hit a submit record button that loads those values into the table as a new record. I have three problems that I am experiencing.

1.) If the cursor is placed in the drop down menus, and you hit enter twice the record is entered into the table automatically. Is there a way to keep this from happening and only enter the info if the button is pressed?

2.) The list boxes and text boxes are always pre-populated with the first record of the bound table, is there a way to make it so these fields are all bank by default?

3.) I have a cascading set of list boxes and I want to get the first one to be enabled, and the second one to be disabled until the first one is selected.

Any help on any or these issues would be greatly appreciated. I'm trying to stick with designing using the properties sheet of the form in design view, but may look into actual VB code if I can't accomplish these tasks in a GUI.
 
(1) Trap the form BeforeUpdate event and cancel it if appropriate.
(2) How should they be populated otherwise? If no data is to be displayed, changed, set their respective control source to Null.
(3) Again, set their respective control source to Null, then populate after the appropriate event.
 
one way is not to bind the form UNTIL you select something form the drop down

then do

me.recordsource = whatever
 
(1) Trap the form BeforeUpdate event and cancel it if appropriate.
(2) How should they be populated otherwise? If no data is to be displayed, changed, set their respective control source to Null.
(3) Again, set their respective control source to Null, then populate after the appropriate event.

I'm pretty new to this type of event handling, could you give me an example of how to do 1 and 3? Do have to write VB functions and place the function names in the boxes next to the event names?

I also have a button, say called button1, that takes the data in the fields and uses that data to add a new record. If I some how figure out how to trap the form beforeupdate event and cancel it as you say in 1, won't that make this button no longer work either?
 
to expand on this - this isnt really a good behaviour to encourage, if you have a form based on a table/query you normally WANT to see the data. The circumstances in which you may not want to see data are

a) you are using the form just to add new items - in which case, make the form a data entry form, then it only adds new items

b) make the form unbound, and manually use code to manipulate the data

c) you want the user to select a record first, and then just display a single record (or small subset) or records



access doesnt need a specific action button to save/sumbit, other than in option b) above. Does one of these describe your circumstance
 
a) you are using the form just to add new items - in which case, make the form a data entry form, then it only adds new items

access doesnt need a specific action button to save/sumbit, other than in option b) above. Does one of these describe your circumstance

This is exactly what I am trying to do. The form is only for data entry. I will try and look online for "data entry form" and see what I get.
 
Ok so I figured out that by not bounding any of the fields to the form, I can get the list boxes from working properly. I have all of the fields filled with the data I want, but now I can't figure out how to append theses values into a new row of a table.

I have created a button and in the "on click" event I have tried to write the following command to take the values and append them to the table, but it does not work.

Code:
Private Sub Command23_Click()
Dim strSQL
strSQL = "INSERT INTO PRETransactions ('TransTypeID','Result')VALUES ('Me!Combo12','Me!Combo22')"
DoCmd.RunSQL strSQL
End Sub

It gives an error saying that TransTypeID does not exist as a field, when it most certainly does. No spelling errors or anything.
 
nono

there is a setting in the forms properties "data" tab

data entry - just set that to YES
 

Users who are viewing this thread

Back
Top Bottom