save value in unbound text box

P

pattlee

Problem: What is the best way to save the user input in an unbound text box?
Need to save it to a table and am not familiar woth VBA. Thanks in advance.
 
N

NetworkTrade

your form is sourced on a table; use a field in that table - even if you have
to add a new field/column to the table.

or use a subform within the form; and source this subform on the table that
will hold the value.
 
K

Klatuu

When you want it to happen will determine where you put the code. The name
are made up as example purposes.

Dim strSQL As String

strSQL = "INSERT INTO SomeTable (FieldName) SELECT """ & Me.SomeTextBox
& """ As Expr1;"
Currentdb.Execute strSQL, dbFailOnError
 
P

pattlee

I want to save the data in the unbound control when I close the form and
before the data is sent to a report. I believe the onclose event is wher I
will place the code... Thanks for your rapid response have been trying to
find examples for this for one solid week. Your answer is crystal clear.
Thanks so much. Will let you know how it works. Regards, Patricia
 
P

pietlinden

Problem: What is the best way to save the user input in an unbound text box?
Need to save it to a table and am not familiar woth VBA. Thanks in advance.

create a textbox that's not visible and write it there in the
BeforeInsert event?

me.HiddenControl=Me.unboundControl
 
P

pietlinden

I want to save the data in the unbound control when I close the form and
before the data is sent to a report.  I believe the onclose event is wher I
will place the code... Thanks for your  rapid response have been tryingto
find examples for this for one solid week. Your answer is crystal clear.
Thanks so much. Will let you know how it works. Regards, Patricia

If you are just *showing* that value on the report, you can set the
control source for the control on the report to

=Forms!MyForm!txtUnboundTextBox

Then you don't have to save the value anywhere. Depends on your
business rules as to how you would do this.
 
P

pattlee

Hi Dave , here is the code as you suggested but it fails at the line
CurrentDb.Execute


'Command Button to submit all user selections to a report.
Private Sub CboSubmit_Click()
'=====================================================
'Code from Dave Hargis, Mocrosoft Access MVP inserted to
'Save the input number to the table Temp in the field NewNumber.
'=====================================================
Dim strSQL As String
strSQL = "INSERT INTO Temp [NewNumber] SELECT """ & Me.txtNewNumber & """
as Expr1;"
CurrentDb.Execute strSQL, dbFailOnError
'=====================================================
the user input is shown but the last line of the code is in yellow....
please advise. Patricia
 
P

pattlee

I am showing the value of the user input on the report exactly as you
indicate, however I must also save this input to a table for future
reference. thanks for your help
 
P

pietlinden

Hi Dave , here is the code as you suggested but it fails at the line
CurrentDb.Execute

'Command Button to submit all user selections to a report.
Private Sub CboSubmit_Click()
'=====================================================
'Code from Dave Hargis, Mocrosoft Access MVP inserted to
'Save the input number to the table Temp in the field NewNumber.
'=====================================================
Dim strSQL As String
strSQL = "INSERT INTO  Temp [NewNumber] SELECT """ & Me.txtNewNumber & """
as Expr1;"
CurrentDb.Execute strSQL, dbFailOnError
'=====================================================
the user input is shown but the last line of the code is in yellow....
please advise. Patricia

Klatuu said:
When you want it to happen will determine where you put the code.  The name
are made up as example purposes.
Dim strSQL As String
   
& """ As Expr1;"
    Currentdb.Execute strSQL, dbFailOnError
"pattlee" wrote:

It should be
strSQL = "INSERT INTO SomeTable (FieldName) VALUES (" &
Me.SomeTextBox & ")"
 
W

Wayne-I-M

I don't understand the bit about the sub-form he refered to but the other
section about saving the contents into a field was right.

Just a question Arno - I have looked at the website you have made regarding
what you see as an abuse of the free peer to peer advice available here -
could it be possibly just a slight over reaction ?
 
W

Wayne-I-M

I am not agreeing with his marketing methods – my personal opinion is that
there should be at least a few places on the web where you can seek genuine
peer to peer advice and expect to receive unbiased suggestions to answer any
question you may have. But, that is only my opinion. I may (and will) argue
my case but I am fully prepared to accept that I may be wrong, you don’t give
anyone this choice.

My initial comment was to question the web site you have created to voice
your objection to this person’s marketing (that’s what it is). Not only are
you (very obviously) opening yourself up to a costly legal claim against
yourself (marketing – in the UK anyway – is not illegal. Not sure about the
USA, never been there, but I understand they do allow adverts on TV, the
web, newspapers, etc) but you are also showing yourself to be a self
appointed policeman seeking to the right the wrongs that you believe are
being done.

This is damaging your argument. There is no recourse for anyone who
disagrees with you, certainly not from the person you are objecting to. If
you were to act more in line with the forum you wish to defend (ie. this one)
in allowing an open discussion on the topic your may well get more sympathy.
Instead it just appears to be nothing more than a rant.

You may wish to create a new topic in Google Discussions and see if others
agree, or not. I imagine they will, but you need to at least give people the
opportunity to disagree.

The internet has become – for better or worst – a marketing tool. The
strategies used may be subtle but they are still there. Is not this forum
just an extension of Microsoft’s marketing strategy? OK it’s useful (I get
loads of information here from people with vastly more experience and skill
than me) but without a “mark-up†would Microsoft spend the time, effort and
costs involved in its creation and maintenance ?

I would think (hope) that most people are now “savvy†enough to see the
difference between freely offered advice and someone asking for credit card
details – even if the 1st approach was to offer advice.

As I said I don’t agree with using a supposedly peer to peer forum to market
your own product. But that’s just my opinion…Isn’t that what the internet is
supposed to be – a place that has at least the semblance of being censorship
free?

Checked with MS Word (hope it’s OK)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top