Log inUsernamePassword
Log me on automatically each visit    
Register
Register
Log in to check your private messages
Log in to check your private messages
Visual Basic Forum for Visual Basic Programmers VB Forum Index » Database & Reporting

Post new topic   Reply to topic
Access Goto page 1, 2  Next
View previous topic :: View next topic  
Author Message
Philwn
Freshman


Joined: 25 Feb 2004
Posts: 40
Location: England

PostPosted: Aug 2nd, 2004 06:02 AM    Post subject: Access Reply with quote

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
View user's profile Send private message Yahoo Messenger MSN Messenger
Avis
Junior Poster


Joined: 07 Oct 2003
Posts: 510
Location: India

PostPosted: Aug 2nd, 2004 06:17 AM    Post subject: Reply with quote

Hello Philwn,

You can use the KeyPress event of the drop down box to update the text boxes. For eg:

[vb:1:da7481908a]Private Sub Combo1_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyReturn Then
'update text box
'code comes in here
End If
End Sub[/vb:1:da7481908a]

Now whenever the user presses the ENTER key the update code will be executed. You can also put this code in LostFocus event. I hope you get it.

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
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger ICQ Number
Philwn
Freshman


Joined: 25 Feb 2004
Posts: 40
Location: England

PostPosted: Aug 2nd, 2004 07:49 AM    Post subject: Reply with quote

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
View user's profile Send private message Yahoo Messenger MSN Messenger
P.T.A.M.
Administrator


Joined: 08 Oct 2003
Posts: 752
Location: Greece

PostPosted: Aug 3rd, 2004 03:42 AM    Post subject: Reply with quote

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 Wink
_________________
No one is completely useless. They can at least be an example of what to avoid.
Back to top
View user's profile Send private message Send e-mail Visit poster's website ICQ Number
Philwn
Freshman


Joined: 25 Feb 2004
Posts: 40
Location: England

PostPosted: Aug 3rd, 2004 09:22 AM    Post subject: thanks Reply with quote

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
View user's profile Send private message Yahoo Messenger MSN Messenger
P.T.A.M.
Administrator


Joined: 08 Oct 2003
Posts: 752
Location: Greece

PostPosted: Aug 4th, 2004 12:43 AM    Post subject: Reply with quote

I don't see anything wrong... Could you post the project with the DB so I can have a look? If you want Smile
_________________
No one is completely useless. They can at least be an example of what to avoid.
Back to top
View user's profile Send private message Send e-mail Visit poster's website ICQ Number
Philwn
Freshman


Joined: 25 Feb 2004
Posts: 40
Location: England

PostPosted: Aug 4th, 2004 02:48 AM    Post subject: i can but may be a while Reply with quote

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
View user's profile Send private message Yahoo Messenger MSN Messenger
Philwn
Freshman


Joined: 25 Feb 2004
Posts: 40
Location: England

PostPosted: Aug 9th, 2004 05:53 AM    Post subject: its an access 2003 Reply with quote

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
View user's profile Send private message Yahoo Messenger MSN Messenger
P.T.A.M.
Administrator


Joined: 08 Oct 2003
Posts: 752
Location: Greece

PostPosted: Aug 9th, 2004 05:55 AM    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website ICQ Number
Avis
Junior Poster


Joined: 07 Oct 2003
Posts: 510
Location: India

PostPosted: Aug 9th, 2004 06:02 AM    Post subject: Reply with quote

Hi Philwn,

I got the db. Now can you explain on what base you want to refresh what text boxes ?

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
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger ICQ Number
Philwn
Freshman


Joined: 25 Feb 2004
Posts: 40
Location: England

PostPosted: Aug 9th, 2004 07:12 AM    Post subject: right well Reply with quote

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
View user's profile Send private message Yahoo Messenger MSN Messenger
Avis
Junior Poster


Joined: 07 Oct 2003
Posts: 510
Location: India

PostPosted: Aug 9th, 2004 08:13 AM    Post subject: Reply with quote

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 Smile

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
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger ICQ Number
Philwn
Freshman


Joined: 25 Feb 2004
Posts: 40
Location: England

PostPosted: Aug 10th, 2004 03:04 AM    Post subject: Reply with quote

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
View user's profile Send private message Yahoo Messenger MSN Messenger
Avis
Junior Poster


Joined: 07 Oct 2003
Posts: 510
Location: India

PostPosted: Aug 10th, 2004 05:12 AM    Post subject: Reply with quote

hello Philwn,

I forgot to mention you need to add a refrence to your VB project. You can do it by going Project > Refrences > Microsoft ActiveX Data Objects 2.5 Library (Check this and Press OK).

Then try executing the project without any changes. I have not implemented the serial_number thing yet so you don't have to change it. Just set the refrence as i mentioned above and run the project.

Hope this helps!

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
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger ICQ Number
Philwn
Freshman


Joined: 25 Feb 2004
Posts: 40
Location: England

PostPosted: Aug 10th, 2004 07:50 AM    Post subject: Reply with quote

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
View user's profile Send private message Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Visual Basic Forum for Visual Basic Programmers VB Forum Index » Database & Reporting All times are GMT - 5 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Visual Basic Forum runs phpBB | Forum Template © iOptional
VB Resources | SSL | Visual Basic