Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 18th, 2010, 10:27 AM
Registered User
 
Join Date: May 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Microsoft Access Command Buttons for subforms

Microsoft Access Command Buttons for subforms

I'm creating forms for a medical Chart database and I'm looking to have Command buttons to open forms and have them auto populate the Patients unique Patient ID number. I've set the primary Key as the Patient ID but when I add in the Command buttons they are not populating the Patient Id.

Also a different Issue I'm having I've set field size as 1 and would like after that one number is entered in for it to auto tab to the next line. I'm not sure what I'm doing wrong with that also.


I'm a bit new to access so any help would be very appreciated.
I'm trying to get this database up and running today... ?

Last edited by crystal100472; May 18th, 2010 at 10:31 AM..
Reply With Quote
  #2 (permalink)  
Old May 18th, 2010, 10:32 AM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Really hard to help you if we don't see what you are doing...
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========
Reply With Quote
  #3 (permalink)  
Old May 18th, 2010, 10:52 AM
Registered User
 
Join Date: May 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by gbianchi View Post
Really hard to help you if we don't see what you are doing...
I'm sorry. I don't know much of the coding of access.

What I do is on the main form I add a command button go through the steps off adding it link it to a form and save and then go to test it and it opens up the form but not with the PatientID auto filled.

Does that make any sense?
Reply With Quote
  #4 (permalink)  
Old May 18th, 2010, 11:40 AM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

I don't have much experience on access.. but please tell me that somewhere you put the SQL or the table the data came from, and also that you put the field/s you are using to filter the data...
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========
Reply With Quote
  #5 (permalink)  
Old May 18th, 2010, 11:44 AM
Registered User
 
Join Date: May 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by gbianchi View Post
I don't have much experience on access.. but please tell me that somewhere you put the SQL or the table the data came from, and also that you put the field/s you are using to filter the data...
Yes I have created tables and created forms and subforms. When I put the subform in the main form the linked ID(patientID) is auto filled in the subform.

What i'm trying to do is create a command button using the command button wizard and linking it to the main form and the button works but is not putting the linked patient id field in the form. Am I not explaining this correctly?
Reply With Quote
  #6 (permalink)  
Old May 18th, 2010, 04:21 PM
Friend of Wrox
Points: 4,007, Level: 26
Points: 4,007, Level: 26 Points: 4,007, Level: 26 Points: 4,007, Level: 26
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Lansing, Michigan, USA.
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

The second question is quicker to answer so I'll do that first.

If you have a field, say it's called txtGender (M for Male, F for Female), you can code an afterupdate event. Suppose the next field is called txtAge. Then...

Code:
If Len(Trim(Nz(Me.txtGender,""))) > 0 Then
    Me.txtAge.SetFocus
End If
The code above makes sure the Gender textbox has a value. If it does, it goes on to Age. Note that I didn't make it Q/A the data to see if it made sense, e.g. allow only M or F.

If users use the TAB key after entering data, this afterupdate event is not necessary. If they use the ENTER key, it is. People should get used to tabbing, but some don't.

As for your first question, when you created the subform, the wizard should have asked you to supply and parent/child relationship from form to subform. In your case, it's the Patient ID. That relationship is not created by the addition of a command button. If the command button's function is to add a new record in the subform, note that the Patient ID will not autofill (assuming parent/child link is correct) until after you start entering data in another field in the subform.
__________________
Greg Serrano
Michigan Dept. of Environmental Quality
Air Quality Division
Reply With Quote
  #7 (permalink)  
Old May 18th, 2010, 10:39 PM
Registered User
 
Join Date: May 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Crystal...
what form is the Button on and what form is the resulting Patient ID to be displayed? What is the code behind the ButtonClick event?


as for your second question, use one of the text box's events to trigger the move to the field. Such as OnKeyPress (I haven't used Access for awhile so this may not be a valid event) the point being, there are events that occur when a key is pressed on the keyboard and they can be captured via code to do some type of work

ex: If somekeyevent then
do what I want
end if

I hope this makes sense
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
datagrid command buttons CyberW ASP.NET 3.5 Basics 21 November 29th, 2008 04:02 PM
Using command buttons in Access kelljw Access VBA 10 July 5th, 2006 12:42 PM
Using command buttons in Access kelljw BOOK: Beginning Visual Basic 2005 Databases ISBN: 978-0-7645-8894-5 1 July 4th, 2006 07:21 AM
Graphics For Command Buttons Teqlump Access 1 November 24th, 2004 11:02 AM
Datagrid command buttons badgolfer ASP.NET 1.0 and 1.1 Basics 22 July 27th, 2004 02:42 AM



All times are GMT -4. The time now is 02:38 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.