move next record (1 Viewer)

gpoogles

Registered User.
Local time
Tomorrow, 01:00
Joined
Jul 24, 2015
Messages
10
Hello everyone...

I'm developing a project with with some field need to be filled with the users
(ie emp ID, emp name, case ref, amount, processing date and status) in excel vba userform.
I'm using msaccess 2003 as a backend

Same fields are used in access table (ie emp_ID, emp_name, caseref, vdate and vstatus) all are text fields...

Userform controls

Emp ID - txtempid
Emp name - txtempname
Case ref - txtcaseref
Amount - txtamount
Processing date - txtdate
Status - txtstatus

Save - cmdsave
Find - cmdfind

My query is to find a record by using case ref number from the access table
Every time I press the find button it should populate the other result into the relevant text boxes for that particular case ref number.

Caseref field is not a primary key set, it will contain the repeated number with different other details


Example
In my table the case ref entered two times with different different other fields

Empid1 - empname1 - caseref1 - 10000 - 12/08/2015
Empid2 - empname2 - caseref1 - 5000 - 13/09/2014
Empid3 - empname3 - caseref1 - 900 - 09/12/2015
 

Ranman256

Well-known member
Local time
Today, 15:30
Joined
Apr 9, 2015
Messages
4,339
why are you using excel? just have the users enter the data into an access form (frontend)

ZERO coding needed. And they dont need Access, use access runtime (free)
 

gpoogles

Registered User.
Local time
Tomorrow, 01:00
Joined
Jul 24, 2015
Messages
10
Its complicated mate, we cannot use access runtime or any other in our systems, also every system does not have ms-access installed, so I'm using excel userform as front end, if you can please give me a solution for my previous post,

Thanks is advance mate....
 

Rabbie

Super Moderator
Local time
Today, 20:30
Joined
Jul 10, 2007
Messages
5,906
We need more information from you if we are going to help you. I gather that this is really an Excel app and you just want a little information from the access table. Is this correct? The more info you give us the more likely it is that you will receive a helpful answer
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 03:30
Joined
May 7, 2009
Messages
19,227
also every system does not have ms-access installed

make a module, and paste this code, but i dont think it will work if dont have access installed.

Code:
Dim conn As Object
Dim objRecordset As Object
Set conn = CreateObject("ADODB.Connection")
'conn.Provider = "Microsoft.Jet.OLEDB.4.0"
conn.provider = "Microsoft.ACE.OLEDB.12.0"
conn.Open "z:\YearOnlyEdit.accdb"
Set objRecordset = CreateObject("ADODB.recordset")
objRecordset.activeconnection = conn
objRecordset.Source = "select * from table where field1 = 'asdf'"
objRecordset.Open
'do you work here

objRecordset.Close
conn.Close
 

gpoogles

Registered User.
Local time
Tomorrow, 01:00
Joined
Jul 24, 2015
Messages
10
Thanks arnelgp,

Its working, however when I press again the find button its not showing the other results with same search field
 

gpoogles

Registered User.
Local time
Tomorrow, 01:00
Joined
Jul 24, 2015
Messages
10
This my coding

Private Sub CormandButton1 Click ()
Dim conn As Object
Dim objRecordset Äs Object
Set conn = CreateObject ("ÄDODB. Connection")
conn.provider = "Microsoft.ÄCE.OLEDB.12.0"
conn.Open "D:\Database1. accdb"
Set objRecordset = CreateObject("ÄDODB.Recordset")
objRecordset.activeconnection = conn
objRecordset.Source = "SELECT * FROM dbsample WHERE emp_name = '"& txtname.Text &"' "
objRecordset.Open
txtid. Text = objRecordset ! emp_id. Value
ObjRecordset.MOveNext
obj Recordset. Close
Conn.Close
End sub


Table contains 2 fields
ie
emp_name emp_ID
Prasad 111111
Prasad 222222

My search text is 'prasad' it has two IDs with same name
After I enter 'Prasad' in the search box and pressed "find" button
Its showing same ID in the txtid box
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 03:30
Joined
May 7, 2009
Messages
19,227
here is the complete code that you should have:
Code:
Option Compare Database
Option Explicit

Dim conn As Object
Dim objRecordset Äs Object

Private Sub CormandButton1_Click ()

    If conn Is Nothing Then
    
        Set conn = CreateObject("ÄDODB. Connection")
    
        conn.provider = "Microsoft.ÄCE.OLEDB.12.0"
        conn.Open "D:\Database1. accdb"
    End If
    If objRecordset Is Nothing Then 
        Set objRecordset = CreateObject("ÄDODB.Recordset")
    
        objRecordset.activeconnection = conn
        objRecordset.Source = "SELECT * FROM dbsample WHERE emp_name = '" & txtname.Text & "' "
        objRecordset.Open
        objRecordset.MoveFirst
    Else
        If Not objRecodset.EOF Then
            objRecordset.MoveNext
            If objRecordset.EOF Then
                objRecordset.MovePrevious
                MsgBox "End of File reached!"
            End If
        Else
            MsgBox "End of File raeched."
        End If
    End If
    txtid.Text = objRecordset!emp_id.Value

End Sub

Private Sub txtname_AfterUpdate()

    If Not objRecordset Is Nothing Then objRecordset.Close: Set objRecordset = Nothing
    If Not conn Is Nothing Then conn.Close: Set conn = Nothing
End Sub


Private Sub Form_Unload(Cancel As Integer)
    Call txtname_AfterUpdate
End Sub
 
Last edited:

gpoogles

Registered User.
Local time
Tomorrow, 01:00
Joined
Jul 24, 2015
Messages
10
Its working amazing man, thankyou so .......much��
 

Users who are viewing this thread

Top Bottom