Solved Simple and stupid question.. (1 Viewer)

mloucel

Member
Local time
Yesterday, 19:27
Joined
Aug 5, 2020
Messages
189
I can see the smiles in many of you, but I just can't figure out what to do....
The problem:
I have a form, and I have a specific record I need to retrieve, I am 100% sure of the ID of the record, I don't need to search 100's of records and display them, that was done already, this particular form requires the EU [End User] to know exactly the ID, enter that ID, click "Retrieve Record" and simply check if the typed number is correct (EU can make a mistake) and display the record so they can edit that specific record, of course if they made a mistake display "Record not found please correct".

So the form must start as a blank form no data whatsoever.
EU enters the ID, clicks the button and either he finds the record or displays a message.
if found
the EU can make changes to the record except the ID

Is that simple, but I have tried a few things and my brain is completely washed, incredible that the most easiest of the tasks I cannot do while some more complex I was able to find a solution.

I created a DEMO database that I've been playing with, but in a frustration moment I delete the damn thing, so I rebuild enter some bogus data with hope that someone can guide me towards the right way to do what I want.

Sorry if this is confusing I cannot believe myself.

Thanks for your help.

Maurice.

PS/ In this demo table the ID I know and I use to search is called Emp_ID so that will be the only field the EU cannot edit.
 

Attachments

  • DemoTemp.accdb
    704 KB · Views: 344

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 10:27
Joined
May 7, 2009
Messages
19,249
see the code behind the form.
 

Attachments

  • DemoTemp.accdb
    912 KB · Views: 155

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 03:27
Joined
Jul 9, 2003
Messages
16,397
Dam ArnelGP you beat me to it!!!
 

Attachments

  • DemoTemp.accdb
    1.4 MB · Views: 350

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 03:27
Joined
Jul 9, 2003
Messages
16,397
The Code:-

Code:
Option Compare Database
Option Explicit

Private Sub btnRetrieveRec_Click()
    Me.RecordSource = "SELECT * FROM DemoTable WHERE Emp_ID=" & Chr(34) & Me.txtGetID & Chr(34)
        If Me.RecordsetClone.EOF Then
            MsgBox " >>> " & "The ID > " & Me.txtGetID & " < Entered is Incorrect Please Check & Enter it Again"
        End If
End Sub      'btnRetrieveRec_Click
 
Last edited:

mloucel

Member
Local time
Yesterday, 19:27
Joined
Aug 5, 2020
Messages
189
Dam ArnelGP you beat me to it!!!
Thanks same concept as Arnel, but diff method
The Code:-

Code:
Option Compare Database
Option Explicit

Private Sub btnRetrieveRec_Click()
    Me.RecordSource = "SELECT * FROM DemoTable WHERE Emp_ID=" & Chr(34) & Me.txtGetID & Chr(34)
        If Me.RecordsetClone.EOF Then
            MsgBox " >>> " & "The ID > " & Me.txtGetID & " < Entered is Incorrect Please Check & Enter it Again"
        End If
End Sub      'btnRetrieveRec_Click
That is sot of what I was doing, I can see on your code my mistake, but I like Arnel's alternative, specially the use of NEW REC to display a blank screen, thanks, I do appreciate your input.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 10:27
Joined
May 7, 2009
Messages
19,249
you can also use combo, so EU can make small mistake.
see frm_retrieve2:
 

Attachments

  • DemoTemp.accdb
    1 MB · Views: 339

mloucel

Member
Local time
Yesterday, 19:27
Joined
Aug 5, 2020
Messages
189
you can also use combo, so EU can make small mistake.
see frm_retrieve2:
yes I see your point but imagine the database with 3000 names, combo won't work, I have a question thou, how do I stop the EU to make any type of modification to the Emp_ID once they start editing the record, I don't want that specific field to be changed, that'll mess up the whole database.
I've tried
me!emp_ID.locked=true
me.Emp_ID.locked=true
and I always get an error
of couse I have to enable that again once I call LockIt().

Why that doesn't work for me?

Thanks Arnel
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 10:27
Joined
May 7, 2009
Messages
19,249
the emp_id won't get modified, the textbox is unbound.
making changes to this textbox is another candidate for
a search parameter.
 

Users who are viewing this thread

Top Bottom