Dont loose the display information

rudy78

Registered User.
Local time
Today, 16:35
Joined
Feb 8, 2010
Messages
16
I'm designing a form where certain data like names should be displayed all the time. I'm using a different table to get the names (drop down button). but everytime i save the record i loose all the input info including the names. Whereas i need to keep those names until I change them.

How can i let the names appear in the forms-window untill i change them manually?
:confused:
 
Are you saying that you want the last selection in the Combo Box to become the default value for the combo box or are you trying to achieve something different?

If it is yes to option one then use the following in combo's after update event;
Code:
Me.YourComboName.DefaultValue = Me.YourComboName
 
Actually, John, I think that needs to be

Code:
Me.YourComboName.DefaultValue = """" & Me.YourComboName & """"
 
Actually, John, I think that needs to be

Code:
Me.YourComboName.DefaultValue = """" & Me.YourComboName & """"

Or, I believe this will work if you want fewer quotes:

Code:
Me.YourComboName.DefaultValue = Chr(34) & Me.YourComboName & Chr(34)
 
thanks guys. i'm going to try it out straight away
 
I've tried it. but what happens now is that I cant add a name at all! it stays blank.
I've used the following syntax in the after update event:
Me.Push Out.DefaultValue = Chr(34) & Me.Push Out & Chr(34)

is there anything that i do wrong?:confused:
 
i still ahve some other issues.
I like to start with a new record when i open my form. However at the moment I get to see the first record in the table.

is there anything i can change to get a new record when i open the form?
 
With regards to not being able to add names to the Combo, is the Combo's Limit To List Property set to Yes?

If you wish to open the form at a new record you can Set the Form's Data Entry property to Yes this will however mean that you can not browse old records whilst that property is set to Yes. Alternatively you could use the following in the Form's On Load event;
Code:
DoCmd.GoToRecord , , acNewRec
 
the combo is set to Yes. I tried to change it to no but it comes up with an error message.

regards
DoCmd.GoToRecord , , acNewRec

It comes up when I save it with: DoCmd is not a recognised Macro.
 
It comes up when I save it with: DoCmd is not a recognised Macro.

Sounds like you're trying to put it in the wrong spot. It sounds like you are trying to put it in the Event PROPERTY and not the VBA Window.

See here for a visual on how to get to the VBA Window (just make sure to use the right event as this example shows a different one than what you want).
 
I've tried that as well and it still comes up with the same message.
 
Which version of Access are you using?
 
i can add my form if you wish to see what's wrong....
 
When you tried it in the VBA code window, did you remember to delete it from the Property sheet? The fact that Access is stilling calling it a Macro indicates it still appears there.
 
There are a couple of issues that might be relevant here.

Forms that you code directly using VBA can have multi-purpose fields within limits, but the stuff the wizards create just ain't that smart for anything except a good starting point. Code and controls created by the form's control wizards will generally be limited to single functionality.

If you have a bound form (i.e. the form has a ROWSOURCE) and your name that you want to be "sticky" is also bound (has a RECORDSOURCE), then this name can either be a selector (a method of choosing a record) or a result (something found in a record) but not usually both. Ask yourself whether what you are doing is trying to mix purposes. Post a little more about what you want this "sticky" name to do.

Off the top of my head, the EASIEST way to do this is to have the information in an unbound text box. You put it there by any of several ways, but since there is an element of volition involved I might use a button-click to copy the required data via some VBA code.

Two warnings.

First - if any untrapped error occurs (ON ERROR GOTO xxx), all data on the form "goes away" because the error handler trashes the program stack. And that is where the "local" variables are kept. Which means they go away.

Second - if the form is even partially bound, some controls are going to be reset when the form goes through its FORM_CURRENT event, even if you didn't build any VBA code for that event. So what you want cannot be both bound and persistent at the same time except by accident.
 
Actually, John, I think that needs to be

Code:
Me.YourComboName.DefaultValue = """" & Me.YourComboName & """"

Could someone explain the rational behind the """" in the above as;
Code:
Me.YourComboName.DefaultValue =  Me.YourComboName
seems to work fine in the sample DB I posted earlier :confused:
 
John, I believe it's got something to do with parsing the right data types. The default value has to have the same data type as the field in which it is used. It has had me stumped before. I bet missinglinq would have a better explanation :)
 
I'm sure there is a very good reason for them, I'd like to know what it is for my own edification :)
 

Users who are viewing this thread

Back
Top Bottom