Go Back   Access World Forums > Microsoft Access Discussion > Forms

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 07-28-2019, 11:19 PM   #1
simonwait
Newly Registered User
 
Join Date: Jul 2019
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
simonwait is on a distinguished road
Data in form combobox needs to retrieve data as read only

Hi

Although I do quite a bit in VB6 and VBA in Excel, Access has always been harder for me to grasp so I'm here as a newbie looking for some help!

I have a form which I would like to use a drop-down list of players in a football team. On selection, the form should populate a few text boxes and then buttons on the form are used to generate pdfs, etc of information about the player.

This all works great but i find that when i look at my data, players are having their data overwritten with other players info! I assume this is because it is being updated when i select a new player.

I tried playing with the allow edit, allow addition etc parameters for the form but then reached a point where nothing happened on the dropdown event.

The event actually triggers some VBA (which may actually be the wrong thing to do but given my background that where i headed!).

Code:
  Me.PlayerName = DLookup("PlayerName", "ActivePlayers", "ActivePlayers.PlayerName=""" & Me.Player.Value & """")
    Me.DOB = DLookup("DOB", "ActivePlayers", "ActivePlayers.PlayerName=""" & Me.Player.Value & """")
    Me.Address = DLookup("Address", "ActivePlayers", "ActivePlayers.PlayerName=""" & Me.Player.Value & """")
    Me.School = DLookup("School", "ActivePlayers", "ActivePlayers.PlayerName=""" & Me.Player.Value & """")
    Me.Parent1Name = DLookup("Parent1Name", "ActivePlayers", "ActivePlayers.PlayerName=""" & Me.Player.Value & """")
    Me.Parent1Email = DLookup("Parent1Email", "ActivePlayers", "ActivePlayers.PlayerName=""" & Me.Player.Value & """")
    Me.Parent1Phone = DLookup("Parent1Phone", "ActivePlayers", "ActivePlayers.PlayerName=""" & Me.Player.Value & """")
    Me.Parent2Name = DLookup("Parent2Name", "ActivePlayers", "ActivePlayers.PlayerName=""" & Me.Player.Value & """")
    Me.Parent2Email = DLookup("Parent2Email", "ActivePlayers", "ActivePlayers.PlayerName=""" & Me.Player.Value & """")
    Me.Parent2Phone = DLookup("Parent2Phone", "ActivePlayers", "ActivePlayers.PlayerName=""" & Me.Player.Value & """")
    'Me.Photo.Picture = DLookup("Photo", "ActivePlayers", "ActivePlayers.PlayerName='" & Me.Player.Value & "'")
    Me.Whatsapp = DLookup("WhatsappGroup", "ActivePlayers", "ActivePlayers.PlayerName=""" & Me.Player.Value & """")
Ultimately I would like to be able to change the data via the form but maybe only by changing the data and then clicking a save button. By default i want this to act more as a read-only form.

I hope my ramblings make sense. Many thanks in advance

simonwait is offline   Reply With Quote
Old 07-29-2019, 12:35 AM   #2
CJ_London
Super Moderator
 
Join Date: Feb 2013
Location: UK
Posts: 11,333
Thanks: 40
Thanked 3,670 Times in 3,538 Posts
CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light CJ_London is a glorious beacon of light
Re: Data in form combobox needs to retrieve data as read only

looks like you are going about this in completely the wrong way. You should bind your form to activeplayers then in the combo after update event apply a filter. You should also have a primary key - what if you have two players with the same name?
__________________
CJ_London
_______________________
A little thanks goes a long way. If you have found this post useful, please tick the thanks button
CJ_London is offline   Reply With Quote
Old 07-29-2019, 12:38 AM   #3
arnelgp
error reading drive A:
 
arnelgp's Avatar
 
Join Date: May 2009
Location: somewhere out there
Posts: 8,568
Thanks: 68
Thanked 2,744 Times in 2,629 Posts
arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice
Re: Data in form combobox needs to retrieve data as read only

if u make those textboxes Unbound, no control source, it will not be overwritten.

__________________
"Never stop learning, because life never stops teaching"
arnelgp is offline   Reply With Quote
Old 07-30-2019, 09:53 AM   #4
simonwait
Newly Registered User
 
Join Date: Jul 2019
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
simonwait is on a distinguished road
Re: Data in form combobox needs to retrieve data as read only

Hi, sorry I couldn't find the thread for a while. Thank you both for your help. I actually used arnelgp's solution but agree with CJ_London's comments regarding the primary key - there is one in the table but wasn't utilizing that in the form so I am now.

simonwait is offline   Reply With Quote
Reply

Tags
form , read only mode

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to enable vba code to read and retrieve data from table? luzz Queries 5 09-05-2017 02:43 AM
how to retrieve data from access table into form? luzz Queries 3 08-28-2017 01:19 AM
retrieve data from table to a label in a form sunny_mel2001 Modules & VBA 3 04-14-2012 08:10 PM
Form to Retrieve and edit data ??? WineSnob Forms 4 05-24-2011 03:18 PM
appending table with ComboBox Data and the other data located on the form lebouffonvert Forms 2 01-28-2007 12:17 PM




All times are GMT -8. The time now is 04:32 AM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World