A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Can I modify A Text Box under program control?



 
 
Thread Tools Display Modes
  #1  
Old August 28th, 2007, 12:14 PM posted to microsoft.public.access.gettingstarted
Ray C
external usenet poster
 
Posts: 215
Default Can I modify A Text Box under program control?

I have a number of "Bound" Text Boxes that display the appropriate records in
a Table (e.g. Mame, Address, etc) but I will want to add new records at some
time and I also Duplicate those same Text Boxes and have them "Unbound" so
that I can enter new info into them. I then I write that data to a new record
by using the following :- where ****TxtBox is the "Unbound" Text Box.

Private Sub SaveRecord()

Dim db As Database, rs1 As Recordset

Set db = CurrentDb
Set rs1 = db.OpenRecordset("tbl_Customer", dbOpenDynaset)
rs1.MoveLast
With rs1
.AddNew ' Add new record to end of Recordset
Object.
![Name] = NameTxtBox
![Addr1] = Addr1TxtBox
![Addr2] = Addr2TxtBox
Etc, Etc
.Update
End With
rs1.Close: db.Close

End Sub

If I could change the Text Box under Program control, it would save
duplicating all those extra boxes.

Or is there a better way to do it?

Thanks RayC

  #2  
Old August 28th, 2007, 12:36 PM posted to microsoft.public.access.gettingstarted
scubadiver
external usenet poster
 
Posts: 1,673
Default Can I modify A Text Box under program control?


What are you trying to do? Sounds very confused to me.


--
The 11th day of every month:

http://truthaction.org/forum/index.php


"Ray C" wrote:

I have a number of "Bound" Text Boxes that display the appropriate records in
a Table (e.g. Mame, Address, etc) but I will want to add new records at some
time and I also Duplicate those same Text Boxes and have them "Unbound" so
that I can enter new info into them. I then I write that data to a new record
by using the following :- where ****TxtBox is the "Unbound" Text Box.

Private Sub SaveRecord()

Dim db As Database, rs1 As Recordset

Set db = CurrentDb
Set rs1 = db.OpenRecordset("tbl_Customer", dbOpenDynaset)
rs1.MoveLast
With rs1
.AddNew ' Add new record to end of Recordset
Object.
![Name] = NameTxtBox
![Addr1] = Addr1TxtBox
![Addr2] = Addr2TxtBox
Etc, Etc
.Update
End With
rs1.Close: db.Close

End Sub

If I could change the Text Box under Program control, it would save
duplicating all those extra boxes.

Or is there a better way to do it?

Thanks RayC

  #3  
Old August 28th, 2007, 01:48 PM posted to microsoft.public.access.gettingstarted
Ray C
external usenet poster
 
Posts: 215
Default Can I modify A Text Box under program control?

It's only confusing because You know what I should be diong and I don't know
what I am doing :-)
I have a Form and I have Text Boxes on thst Form that are "Bound" to fields
in a Table. This is great if all I want to do is look at the information in
that Table but I might want to add a new record at some time and it is this
that I am working my way through. I don't have navigation Buttons on my Form
so I am not able to go to the last record and enter new information then
save. Could I do that under program control?
Hope this helps RayC

"scubadiver" wrote:


What are you trying to do? Sounds very confused to me.


--
The 11th day of every month:

http://truthaction.org/forum/index.php


"Ray C" wrote:

I have a number of "Bound" Text Boxes that display the appropriate records in
a Table (e.g. Mame, Address, etc) but I will want to add new records at some
time and I also Duplicate those same Text Boxes and have them "Unbound" so
that I can enter new info into them. I then I write that data to a new record
by using the following :- where ****TxtBox is the "Unbound" Text Box.

Private Sub SaveRecord()

Dim db As Database, rs1 As Recordset

Set db = CurrentDb
Set rs1 = db.OpenRecordset("tbl_Customer", dbOpenDynaset)
rs1.MoveLast
With rs1
.AddNew ' Add new record to end of Recordset
Object.
![Name] = NameTxtBox
![Addr1] = Addr1TxtBox
![Addr2] = Addr2TxtBox
Etc, Etc
.Update
End With
rs1.Close: db.Close

End Sub

If I could change the Text Box under Program control, it would save
duplicating all those extra boxes.

Or is there a better way to do it?

Thanks RayC

  #4  
Old August 28th, 2007, 01:54 PM posted to microsoft.public.access.gettingstarted
scubadiver
external usenet poster
 
Posts: 1,673
Default Can I modify A Text Box under program control?


It does sound like you want a 1-to-many relationship! Do you have one table
at the moment? If so, what are the fields?

--
The 11th day of every month:

http://truthaction.org/forum/index.php


"Ray C" wrote:

It's only confusing because You know what I should be diong and I don't know
what I am doing :-)
I have a Form and I have Text Boxes on thst Form that are "Bound" to fields
in a Table. This is great if all I want to do is look at the information in
that Table but I might want to add a new record at some time and it is this
that I am working my way through. I don't have navigation Buttons on my Form
so I am not able to go to the last record and enter new information then
save. Could I do that under program control?
Hope this helps RayC

"scubadiver" wrote:


What are you trying to do? Sounds very confused to me.


--
The 11th day of every month:

http://truthaction.org/forum/index.php


"Ray C" wrote:

I have a number of "Bound" Text Boxes that display the appropriate records in
a Table (e.g. Mame, Address, etc) but I will want to add new records at some
time and I also Duplicate those same Text Boxes and have them "Unbound" so
that I can enter new info into them. I then I write that data to a new record
by using the following :- where ****TxtBox is the "Unbound" Text Box.

Private Sub SaveRecord()

Dim db As Database, rs1 As Recordset

Set db = CurrentDb
Set rs1 = db.OpenRecordset("tbl_Customer", dbOpenDynaset)
rs1.MoveLast
With rs1
.AddNew ' Add new record to end of Recordset
Object.
![Name] = NameTxtBox
![Addr1] = Addr1TxtBox
![Addr2] = Addr2TxtBox
Etc, Etc
.Update
End With
rs1.Close: db.Close

End Sub

If I could change the Text Box under Program control, it would save
duplicating all those extra boxes.

Or is there a better way to do it?

Thanks RayC

  #5  
Old August 28th, 2007, 02:40 PM posted to microsoft.public.access.gettingstarted
Ray C
external usenet poster
 
Posts: 215
Default Can I modify A Text Box under program control?

This is a fundmental problem for me that relates to a number of different
tables but, For the sake of simplicity, I have a Customer Table containing
Cusomer Name, Address, Contact, etc, etc. (if you want the specific field
names, let me know and I will list them for you. I have a Form called
frm_Main (that has it's Record Source as a Query, for various reasons) and on
that form are Text Boxes that have their record Source as the Fields in the
Query. They will display the information held in the Fields in the table that
the Query is based on. The way I do this is to have a Combo Box give me a
list of all the available info and when I select one, I use the information
held in the Combo to lookup and set a "Bookmark" in the Dynaset. This will
display the required record in the "Bound" Text Boxes. This all works OK but
when I want to Add a New Record I am not able to do that without gathering
all the new info in a parallel set of "Unbound" Text Boxes and then writing
that information to the table seperately.

Hope this helps Ray C

"scubadiver" wrote:


It does sound like you want a 1-to-many relationship! Do you have one table
at the moment? If so, what are the fields?

--
The 11th day of every month:

http://truthaction.org/forum/index.php


"Ray C" wrote:

It's only confusing because You know what I should be diong and I don't know
what I am doing :-)
I have a Form and I have Text Boxes on thst Form that are "Bound" to fields
in a Table. This is great if all I want to do is look at the information in
that Table but I might want to add a new record at some time and it is this
that I am working my way through. I don't have navigation Buttons on my Form
so I am not able to go to the last record and enter new information then
save. Could I do that under program control?
Hope this helps RayC

"scubadiver" wrote:


What are you trying to do? Sounds very confused to me.


--
The 11th day of every month:

http://truthaction.org/forum/index.php


"Ray C" wrote:

I have a number of "Bound" Text Boxes that display the appropriate records in
a Table (e.g. Mame, Address, etc) but I will want to add new records at some
time and I also Duplicate those same Text Boxes and have them "Unbound" so
that I can enter new info into them. I then I write that data to a new record
by using the following :- where ****TxtBox is the "Unbound" Text Box.

Private Sub SaveRecord()

Dim db As Database, rs1 As Recordset

Set db = CurrentDb
Set rs1 = db.OpenRecordset("tbl_Customer", dbOpenDynaset)
rs1.MoveLast
With rs1
.AddNew ' Add new record to end of Recordset
Object.
![Name] = NameTxtBox
![Addr1] = Addr1TxtBox
![Addr2] = Addr2TxtBox
Etc, Etc
.Update
End With
rs1.Close: db.Close

End Sub

If I could change the Text Box under Program control, it would save
duplicating all those extra boxes.

Or is there a better way to do it?

Thanks RayC

  #6  
Old August 28th, 2007, 02:54 PM posted to microsoft.public.access.gettingstarted
scubadiver
external usenet poster
 
Posts: 1,673
Default Can I modify A Text Box under program control?


It sounds to me that your source query is not updateable. if you open the
query will it allow you to alter records?

--

http://www.ready4mainstream.ny911truth.org/index.html


"Ray C" wrote:

This is a fundmental problem for me that relates to a number of different
tables but, For the sake of simplicity, I have a Customer Table containing
Cusomer Name, Address, Contact, etc, etc. (if you want the specific field
names, let me know and I will list them for you. I have a Form called
frm_Main (that has it's Record Source as a Query, for various reasons) and on
that form are Text Boxes that have their record Source as the Fields in the
Query. They will display the information held in the Fields in the table that
the Query is based on. The way I do this is to have a Combo Box give me a
list of all the available info and when I select one, I use the information
held in the Combo to lookup and set a "Bookmark" in the Dynaset. This will
display the required record in the "Bound" Text Boxes. This all works OK but
when I want to Add a New Record I am not able to do that without gathering
all the new info in a parallel set of "Unbound" Text Boxes and then writing
that information to the table seperately.

Hope this helps Ray C

"scubadiver" wrote:


It does sound like you want a 1-to-many relationship! Do you have one table
at the moment? If so, what are the fields?

--
The 11th day of every month:

http://truthaction.org/forum/index.php


"Ray C" wrote:

It's only confusing because You know what I should be diong and I don't know
what I am doing :-)
I have a Form and I have Text Boxes on thst Form that are "Bound" to fields
in a Table. This is great if all I want to do is look at the information in
that Table but I might want to add a new record at some time and it is this
that I am working my way through. I don't have navigation Buttons on my Form
so I am not able to go to the last record and enter new information then
save. Could I do that under program control?
Hope this helps RayC

"scubadiver" wrote:


What are you trying to do? Sounds very confused to me.


--
The 11th day of every month:

http://truthaction.org/forum/index.php


"Ray C" wrote:

I have a number of "Bound" Text Boxes that display the appropriate records in
a Table (e.g. Mame, Address, etc) but I will want to add new records at some
time and I also Duplicate those same Text Boxes and have them "Unbound" so
that I can enter new info into them. I then I write that data to a new record
by using the following :- where ****TxtBox is the "Unbound" Text Box.

Private Sub SaveRecord()

Dim db As Database, rs1 As Recordset

Set db = CurrentDb
Set rs1 = db.OpenRecordset("tbl_Customer", dbOpenDynaset)
rs1.MoveLast
With rs1
.AddNew ' Add new record to end of Recordset
Object.
![Name] = NameTxtBox
![Addr1] = Addr1TxtBox
![Addr2] = Addr2TxtBox
Etc, Etc
.Update
End With
rs1.Close: db.Close

End Sub

If I could change the Text Box under Program control, it would save
duplicating all those extra boxes.

Or is there a better way to do it?

Thanks RayC

  #7  
Old August 28th, 2007, 03:22 PM posted to microsoft.public.access.gettingstarted
John Spencer
external usenet poster
 
Posts: 2,364
Default Can I modify A Text Box under program control?

Add a button to your form "New Record"

In the click event add code to go to NEW Record.

THe code you need to add for the buttons click event should look
something like

On Error GoTo Err_sCmdAdd

With Me
If .Dirty = True Then .Dirty = False

If .AllowAdditions = False Then
.AllowAdditions = True
End If

DoCmd.GoToRecord , , acNewRec

End With

Exit_sCmdAdd:
Exit Function

Err_sCmdAdd:
MsgBox Err.Number & ": " & Err.Description,



'================================================= ===
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
'================================================= ===


Ray C wrote:
It's only confusing because You know what I should be diong and I don't know
what I am doing :-)
I have a Form and I have Text Boxes on thst Form that are "Bound" to fields
in a Table. This is great if all I want to do is look at the information in
that Table but I might want to add a new record at some time and it is this
that I am working my way through. I don't have navigation Buttons on my Form
so I am not able to go to the last record and enter new information then
save. Could I do that under program control?
Hope this helps RayC

"scubadiver" wrote:

What are you trying to do? Sounds very confused to me.


--
The 11th day of every month:

http://truthaction.org/forum/index.php


"Ray C" wrote:

I have a number of "Bound" Text Boxes that display the appropriate records in
a Table (e.g. Mame, Address, etc) but I will want to add new records at some
time and I also Duplicate those same Text Boxes and have them "Unbound" so
that I can enter new info into them. I then I write that data to a new record
by using the following :- where ****TxtBox is the "Unbound" Text Box.

Private Sub SaveRecord()

Dim db As Database, rs1 As Recordset

Set db = CurrentDb
Set rs1 = db.OpenRecordset("tbl_Customer", dbOpenDynaset)
rs1.MoveLast
With rs1
.AddNew ' Add new record to end of Recordset
Object.
![Name] = NameTxtBox
![Addr1] = Addr1TxtBox
![Addr2] = Addr2TxtBox
Etc, Etc
.Update
End With
rs1.Close: db.Close

End Sub

If I could change the Text Box under Program control, it would save
duplicating all those extra boxes.

Or is there a better way to do it?

Thanks RayC

  #8  
Old August 28th, 2007, 03:40 PM posted to microsoft.public.access.gettingstarted
scubadiver
external usenet poster
 
Posts: 1,673
Default Can I modify A Text Box under program control?


Sounds like you have your answer but I still don't quite understand how your
database works. I think it could be simpler.



"Ray C" wrote:

It's only confusing because You know what I should be diong and I don't know
what I am doing :-)
I have a Form and I have Text Boxes on thst Form that are "Bound" to fields
in a Table. This is great if all I want to do is look at the information in
that Table but I might want to add a new record at some time and it is this
that I am working my way through. I don't have navigation Buttons on my Form
so I am not able to go to the last record and enter new information then
save. Could I do that under program control?
Hope this helps RayC

"scubadiver" wrote:


What are you trying to do? Sounds very confused to me.


--
The 11th day of every month:

http://truthaction.org/forum/index.php


"Ray C" wrote:

I have a number of "Bound" Text Boxes that display the appropriate records in
a Table (e.g. Mame, Address, etc) but I will want to add new records at some
time and I also Duplicate those same Text Boxes and have them "Unbound" so
that I can enter new info into them. I then I write that data to a new record
by using the following :- where ****TxtBox is the "Unbound" Text Box.

Private Sub SaveRecord()

Dim db As Database, rs1 As Recordset

Set db = CurrentDb
Set rs1 = db.OpenRecordset("tbl_Customer", dbOpenDynaset)
rs1.MoveLast
With rs1
.AddNew ' Add new record to end of Recordset
Object.
![Name] = NameTxtBox
![Addr1] = Addr1TxtBox
![Addr2] = Addr2TxtBox
Etc, Etc
.Update
End With
rs1.Close: db.Close

End Sub

If I could change the Text Box under Program control, it would save
duplicating all those extra boxes.

Or is there a better way to do it?

Thanks RayC

  #9  
Old August 28th, 2007, 03:54 PM posted to microsoft.public.access.gettingstarted
Ray C
external usenet poster
 
Posts: 215
Default Can I modify A Text Box under program control?

Yes it will but I think that you are looking to answer for something that I
am not asking.
I Have a Form that has its Source as the Customer Table, I do not show the
navigation bar on that Form. I have Text boxes on that Form that show records
in the Table. I have an "Unbound" Text Box that I use to find the records
that I want to display. All that works Fine.
In that situation, How do I add a new Record? If I Type anything into the
Boxes that are on the Form, they will modify an existing record because they
are "Bound" to the appropriate field"
My answer is to create a new Form and populate it with a Duplicate set of
"Unbound" Text Boxes, type in the relavent information and then save that
information by using the code I indicated earlier.
There is probably a much better way of doing this fundamental action and you
are probably making the assumption that I would not be naive enough not to
use the better method. However, I don't know a better method and what I am
asking is if there is any way I could use the same set of Text Boxes and make
them "Bound" or "Unbound" under program control so that I do not have to
duplicate a whole mess of Text Boxes.
If there is a better way to add records to a Table, please let me know
Thanks RayC

"scubadiver" wrote:


It sounds to me that your source query is not updateable. if you open the
query will it allow you to alter records?

--

http://www.ready4mainstream.ny911truth.org/index.html


"Ray C" wrote:

This is a fundmental problem for me that relates to a number of different
tables but, For the sake of simplicity, I have a Customer Table containing
Cusomer Name, Address, Contact, etc, etc. (if you want the specific field
names, let me know and I will list them for you. I have a Form called
frm_Main (that has it's Record Source as a Query, for various reasons) and on
that form are Text Boxes that have their record Source as the Fields in the
Query. They will display the information held in the Fields in the table that
the Query is based on. The way I do this is to have a Combo Box give me a
list of all the available info and when I select one, I use the information
held in the Combo to lookup and set a "Bookmark" in the Dynaset. This will
display the required record in the "Bound" Text Boxes. This all works OK but
when I want to Add a New Record I am not able to do that without gathering
all the new info in a parallel set of "Unbound" Text Boxes and then writing
that information to the table seperately.

Hope this helps Ray C

"scubadiver" wrote:


It does sound like you want a 1-to-many relationship! Do you have one table
at the moment? If so, what are the fields?

--
The 11th day of every month:

http://truthaction.org/forum/index.php


"Ray C" wrote:

It's only confusing because You know what I should be diong and I don't know
what I am doing :-)
I have a Form and I have Text Boxes on thst Form that are "Bound" to fields
in a Table. This is great if all I want to do is look at the information in
that Table but I might want to add a new record at some time and it is this
that I am working my way through. I don't have navigation Buttons on my Form
so I am not able to go to the last record and enter new information then
save. Could I do that under program control?
Hope this helps RayC

"scubadiver" wrote:


What are you trying to do? Sounds very confused to me.


--
The 11th day of every month:

http://truthaction.org/forum/index.php


"Ray C" wrote:

I have a number of "Bound" Text Boxes that display the appropriate records in
a Table (e.g. Mame, Address, etc) but I will want to add new records at some
time and I also Duplicate those same Text Boxes and have them "Unbound" so
that I can enter new info into them. I then I write that data to a new record
by using the following :- where ****TxtBox is the "Unbound" Text Box.

Private Sub SaveRecord()

Dim db As Database, rs1 As Recordset

Set db = CurrentDb
Set rs1 = db.OpenRecordset("tbl_Customer", dbOpenDynaset)
rs1.MoveLast
With rs1
.AddNew ' Add new record to end of Recordset
Object.
![Name] = NameTxtBox
![Addr1] = Addr1TxtBox
![Addr2] = Addr2TxtBox
Etc, Etc
.Update
End With
rs1.Close: db.Close

End Sub

If I could change the Text Box under Program control, it would save
duplicating all those extra boxes.

Or is there a better way to do it?

Thanks RayC

  #10  
Old August 28th, 2007, 04:30 PM posted to microsoft.public.access.gettingstarted
Ray C
external usenet poster
 
Posts: 215
Default Can I modify A Text Box under program control?

I am sure that it would be a lot simpler if I was cleaverer :-(
Thanks for your help it is very much appreciated,

Rayc

"scubadiver" wrote:


Sounds like you have your answer but I still don't quite understand how your
database works. I think it could be simpler.



"Ray C" wrote:

It's only confusing because You know what I should be diong and I don't know
what I am doing :-)
I have a Form and I have Text Boxes on thst Form that are "Bound" to fields
in a Table. This is great if all I want to do is look at the information in
that Table but I might want to add a new record at some time and it is this
that I am working my way through. I don't have navigation Buttons on my Form
so I am not able to go to the last record and enter new information then
save. Could I do that under program control?
Hope this helps RayC

"scubadiver" wrote:


What are you trying to do? Sounds very confused to me.


--
The 11th day of every month:

http://truthaction.org/forum/index.php


"Ray C" wrote:

I have a number of "Bound" Text Boxes that display the appropriate records in
a Table (e.g. Mame, Address, etc) but I will want to add new records at some
time and I also Duplicate those same Text Boxes and have them "Unbound" so
that I can enter new info into them. I then I write that data to a new record
by using the following :- where ****TxtBox is the "Unbound" Text Box.

Private Sub SaveRecord()

Dim db As Database, rs1 As Recordset

Set db = CurrentDb
Set rs1 = db.OpenRecordset("tbl_Customer", dbOpenDynaset)
rs1.MoveLast
With rs1
.AddNew ' Add new record to end of Recordset
Object.
![Name] = NameTxtBox
![Addr1] = Addr1TxtBox
![Addr2] = Addr2TxtBox
Etc, Etc
.Update
End With
rs1.Close: db.Close

End Sub

If I could change the Text Box under Program control, it would save
duplicating all those extra boxes.

Or is there a better way to do it?

Thanks RayC

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 12:00 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.