borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (easy one.)Next Topic (how to export access table to foxpro/dbase III table by ado??) New Topic New Poll Post Reply
AndreaVB Forum : Database : updating one filed in a form when another is selected
Poster Message
TinyE95
Level: Guest


icon updating one filed in a form when another is selected

I need help, newbie status admitted.
I have a access db with two tables, one named "systems", one named "system_type".
"system type" has two fields, (name), (part_num).

In the form for entry into systems table, I have a list box for the systems(system_name) field, that queries the system_type(name) field.
When selected it enters the data in system_type(name) into systems(system_name).
What I need is for the field system(part_num) in systems table to be auto filled with the value in system_type(part_num) that corresponds to the selection made in the list box.

Can anyone help?
Thank you,

23-09-2002 at 08:19 PM
| Quote Reply
stickleprojects
Level: Moderator


Registered: 09-09-2002
Posts: 891
icon Re: updating one filed in a form when another is selected

Hi
You have a number of methods.
1)
Have a hidden field in your listbox that contains the new field value (part_num).
2)
If using an RDBMS, use a trigger on the main table when updated, this will execute sql in order to populate the other field.
3)
Use the listbox_OnValidate or OnClick methods to execute code to populate the new field from your recordset.
public sub List1_Click
  dim rs as recordset
  set rs=rsMain.Clone
  me.txtField(Part_Num) = rs("Part_Num")
  set rs=nothing
end sub
Of course, this assumes that you have already retrieved the part-num in your main recordset, otherwise
public sub List1_Click
  dim sql as string
  sql="SELECT Part_Num from MyTable WHERE System_Type = " & me.system_type.value
  dim rs as recordset
  set rs=myConnection.ExecuteSQL(sql)
  me.txtMyPartNum=rs("Part_Num")
  set rs=nothing
end sub
Hope this helps
Kieron


____________________________
Build it better, faster, quicker, easier.. then fix it (non-offical MS mission statement)

29-09-2002 at 11:40 PM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : Database : updating one filed in a form when another is selected
Previous Topic (easy one.)Next Topic (how to export access table to foxpro/dbase III table by ado??) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder