473,395 Members | 1,761 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Help~ Update a Text Box associated with a selected Combo box

Private Sub PubName_AfterUpdate()

Dim sql As String
sql = "select PubCode from Publisher where PubName = '" &
PubName.Value & "';"
Set rst = CurrentDb.OpenRecordset(sql)
MsgBox sql
If Not rst.BOF Then
rst.MoveFirst
End If
PubCode.Value = rst(0) <-- error

End Sub

PubCode is a text box and PubName is a combo box.
I have a table like this:
Publisher: PubCode, PubName

and my form is like that...
If I selected a PubName in PubName combo box, I want to change the
PubCode correspondingly, since they are actually refering the same
tuple.

But When I use the above code...
run time error 3331 occur sayign that

To make change in this field, first save the record.

I am getting dizzy~~
Can anyone help?
Thx~

Mar 31 '06 #1
4 4037
"faiyeah" <fa********@gmail.com> wrote in
news:11*********************@j33g2000cwa.googlegro ups.com:
Private Sub PubName_AfterUpdate()

Dim sql As String
sql = "select PubCode from Publisher where PubName = '" &
PubName.Value & "';"
Set rst = CurrentDb.OpenRecordset(sql)
MsgBox sql
If Not rst.BOF Then
rst.MoveFirst
End If
PubCode.Value = rst(0) <-- error

End Sub

PubCode is a text box and PubName is a combo box.
I have a table like this:
Publisher: PubCode, PubName

and my form is like that...
If I selected a PubName in PubName combo box, I want to change
the PubCode correspondingly, since they are actually refering
the same tuple.

But When I use the above code...
run time error 3331 occur sayign that

To make change in this field, first save the record.

I am getting dizzy~~
Can anyone help?
Thx~

Since pubname and pubcode both exist in the same table, put them
both in the combobox. Make the pubcode column = 0", so it's not
visible. Then in the combo box after update, set the textbox
value to the value in the hidden column

PubCode.Value = combobox.column(n) where is the number of the
column, counted left to right.

--
Bob Quintal

PA is y I've altered my email address.
Mar 31 '06 #2
Sorry Bob, I am still not so clear about your idea...
could you be more detail??

Should I create a combobox, with pubname and pubcode and set it
invisible?
and then... what should I do??

Thank you for you great help anyway~

Mar 31 '06 #3
"faiyeah" <fa********@gmail.com> wrote in
news:11**********************@t31g2000cwb.googlegr oups.com:
Sorry Bob, I am still not so clear about your idea...
could you be more detail??

Should I create a combobox, with pubname and pubcode and set it
invisible?
and then... what should I do??

Thank you for you great help anyway~

You already have a combobox, PubCode is a text box and PubName is a combo box

Modify the existing combobox.

--
Bob Quintal

PA is y I've altered my email address.
Mar 31 '06 #4
Thank you.
I have solved it~~

Apr 1 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: mark | last post by:
I've been working on an Access 2000 database for a couple of weeks now. I took a course in access about a year ago, a crash course, and I learned a ton, but I didn't touch Access for the year since...
9
by: Megan | last post by:
Hi- I'm creating a database of music bands with their cds and songs. I'm trying to program an SQL statement so that I can enter a string of text in a textbox, press the 'Enter' key, and have...
5
by: J. Yuan | last post by:
Hi, I am working on a checkout/inventory system. How can I make a button that when pressed, would update the previous fields transaction number to a table (for example, -3 printers, so that...
4
by: jon f kaminsky | last post by:
Hi- I've seen this problem discussed a jillion times but I cannot seem to implement any advice that makes it work. I am porting a large project from VB6 to .NET. The issue is using the combo box...
0
by: faiyeah | last post by:
Private Sub PubName_AfterUpdate() Dim sql As String sql = "select PubCode from Publisher where PubName = '" & PubName.Value & "';" Set rst = CurrentDb.OpenRecordset(sql) MsgBox sql If Not...
5
by: CCLeasing | last post by:
Hello, I have searched google but can not find a straight forward answer to my problem. Hopefuly someone will be kind enough to offer their expertise. Please forgive if this seems a bit convoluted...
0
by: CCLeasing | last post by:
Hello, I have searched google but can not find a straight forward answer to my problem. Hopefuly someone will be kind enough to offer their expertise. Please forgive if this seems a bit convoluted...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
9
by: ajos | last post by:
Hello friends, After thinking about this for sometime, i decided to post this in the java forum. Well my problem here in detail is, i have 3 jsp pages where in a.jsp(for example) i have a combo...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.