| View previous topic :: View next topic |
| Author |
Message |
Philwn Freshman
Joined: 25 Feb 2004 Posts: 40 Location: England
|
Posted: Aug 2nd, 2004 06:02 AM Post subject: Access |
|
|
I have a drop down box in an access database form.
the drop down box has a bunch of serial numbers in, once a serial number has been entered completely or selected it should fetch the other records in the database and update the text boxes on the form.
How would this be possible? _________________ Nothing good to put here |
|
| Back to top |
|
Avis Junior Poster

Joined: 07 Oct 2003 Posts: 510 Location: India
|
|
| Back to top |
|
Philwn Freshman
Joined: 25 Feb 2004 Posts: 40 Location: England
|
Posted: Aug 2nd, 2004 07:49 AM Post subject: |
|
|
yes but my problem is that how do i fetch the the records from the table, i havent done much with databases and vba _________________ Nothing good to put here |
|
| Back to top |
|
P.T.A.M. Administrator

Joined: 08 Oct 2003 Posts: 752 Location: Greece
|
Posted: Aug 3rd, 2004 03:42 AM Post subject: |
|
|
You can loop through the items and find the serial number matches :
[vb:1:d4390296fa]Rs.MoveFirst
Do While Not Rs.EOF
If Rs.Fields("SerialOrWhatever") = cboSerial.Text Then
sometxtbox.Text = Rs.Fields("SomeOther")
anotherone.Text = Rs.Fields("Another")
Exit Do
Else
Rs.MoveNext
End If
Loop[/vb:1:d4390296fa]
I hope it's right, I haven't tested but I think you can see the logic  _________________ No one is completely useless. They can at least be an example of what to avoid. |
|
| Back to top |
|
Philwn Freshman
Joined: 25 Feb 2004 Posts: 40 Location: England
|
Posted: Aug 3rd, 2004 09:22 AM Post subject: thanks |
|
|
thanks ptam i think im gettin closer,
if used the following code:
| Code: | Private Sub Combo90_Enter()
rs.MoveFirst
Do While Not rs.EOF
If rs.Fields("Serials") = Combo90.Text Then
Product_Code.Text = rs.Fields("build_code")
Exit Do
Else
rs.MoveNext
End If
Loop
End Sub |
so that when the serial number is entered and the user presses enter it fetchesthe records from the table called serials. the text box called product code will then equal the field called build code in the serials table. but it aint working its not pulling up an error or anything. any help, thanks for the help so far _________________ Nothing good to put here |
|
| Back to top |
|
P.T.A.M. Administrator

Joined: 08 Oct 2003 Posts: 752 Location: Greece
|
Posted: Aug 4th, 2004 12:43 AM Post subject: |
|
|
I don't see anything wrong... Could you post the project with the DB so I can have a look? If you want  _________________ No one is completely useless. They can at least be an example of what to avoid. |
|
| Back to top |
|
Philwn Freshman
Joined: 25 Feb 2004 Posts: 40 Location: England
|
Posted: Aug 4th, 2004 02:48 AM Post subject: i can but may be a while |
|
|
may be a while tho cos ill have to remove some records as its 17mb and its a database for work so some info will not be aloud transfered with it, ill post when redy tho _________________ Nothing good to put here |
|
| Back to top |
|
Philwn Freshman
Joined: 25 Feb 2004 Posts: 40 Location: England
|
Posted: Aug 9th, 2004 05:53 AM Post subject: its an access 2003 |
|
|
its a database created in access 2003 using VBA within the database, do u have 2003 to use? if not i may be able convert it to older access format _________________ Nothing good to put here |
|
| Back to top |
|
P.T.A.M. Administrator

Joined: 08 Oct 2003 Posts: 752 Location: Greece
|
Posted: Aug 9th, 2004 05:55 AM Post subject: |
|
|
If you could save it as 2000 format it would be nice... :angel: _________________ No one is completely useless. They can at least be an example of what to avoid. |
|
| Back to top |
|
Avis Junior Poster

Joined: 07 Oct 2003 Posts: 510 Location: India
|
|
| Back to top |
|
Philwn Freshman
Joined: 25 Feb 2004 Posts: 40 Location: England
|
Posted: Aug 9th, 2004 07:12 AM Post subject: right well |
|
|
using the code p.t.a.m gave me after altering it to correct names
| Code: | Private Sub Combo90_Enter()
rs.MoveFirst
Do While Not rs.EOF
If rs.Fields("Serials") = Combo90.Text Then
Product_Code.Text = rs.Fields("build_code")
Exit Do
Else
rs.MoveNext
End If
Loop
End Sub |
when a serial number is typed in the serial combo box (combo90.text) and enter is pressed it should fetch the "build code" field from the table called serials depending which serial number is entered. and that build code is added into product_code.text. there are other fields but i thought keep it simple for now once i find out how to do the one i can code the rest myself? do you understand my problem? im not best at explainin _________________ Nothing good to put here |
|
| Back to top |
|
Avis Junior Poster

Joined: 07 Oct 2003 Posts: 510 Location: India
|
Posted: Aug 9th, 2004 08:13 AM Post subject: |
|
|
Hello!
I have made a sample program for you. It can be optimized but for that you have to change the fields name in the table. As you're using "Serial Number" whereas the optimized version requires "Serial_Number".
If you remove the space in the field names then the code in the demo can be optimized and will be more faster and efficient.
I am attaching the project. Also Compact your database. It'll reduct to 200-300 KB instead of MB's
Thanks! _________________ Code Snippets, Tutorials, Utilities, Controls
Low cost Web Hosting
Hosting starts at as low as $4 per year!
Always follow posting guidelines
Put your VB code in [vb ] your code [ /vb] tags! |
|
| Back to top |
|
Philwn Freshman
Joined: 25 Feb 2004 Posts: 40 Location: England
|
Posted: Aug 10th, 2004 03:04 AM Post subject: |
|
|
ok i opened yours and coding was same apart from serial_number but when using it it wouldnt work cos of the visual basic files included with it not because of problems with code didnt even get to testin if code worked or not.
so i read the code and your post and to me it sounded like i just had to change that one part to serial_number, i do that and now the first line of code turns up an error highlighted in yellow (rs.movefirst)
???????????????? _________________ Nothing good to put here |
|
| Back to top |
|
Avis Junior Poster

Joined: 07 Oct 2003 Posts: 510 Location: India
|
|
| Back to top |
|
Philwn Freshman
Joined: 25 Feb 2004 Posts: 40 Location: England
|
Posted: Aug 10th, 2004 07:50 AM Post subject: |
|
|
ok, but i am not creating a seperate vb application im doing it in vba on the form within the database will this still work? _________________ Nothing good to put here |
|
| Back to top |
|
|