Welcome to Dream.In.Code
Become a VB Expert!

Join 149,566 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,640 people online right now. Registration is fast and FREE... Join Now!




Refresh form without exiting or unloading

 
Reply to this topicStart new topic

Refresh form without exiting or unloading

tica0419
13 Nov, 2007 - 11:17 PM
Post #1

New D.I.C Head
*

Joined: 8 Oct, 2007
Posts: 28


My Contributions
hi! i have a form with a hyperlink on a label.. the user adds new data/hyperlink by clicking on the save button righafter putting the URL or path.. but then, all hyperlinks has been disabled rightafter saving the new data.. so i will have to exit the current form and load it again to refresh it.. help? pls?
User is offlineProfile CardPM
+Quote Post

ahmad_511
RE: Refresh Form Without Exiting Or Unloading
14 Nov, 2007 - 01:57 AM
Post #2

D.I.C Regular
Group Icon

Joined: 28 Apr, 2007
Posts: 351



Thanked: 8 times
Dream Kudos: 400
My Contributions
Can you post the code here?, So we can better assist you to find the problem.

Waiting for reply.
Regards
User is offlineProfile CardPM
+Quote Post

tica0419
RE: Refresh Form Without Exiting Or Unloading
19 Nov, 2007 - 11:54 PM
Post #3

New D.I.C Head
*

Joined: 8 Oct, 2007
Posts: 28


My Contributions
QUOTE(ahmad_511 @ 14 Nov, 2007 - 02:57 AM) *

Can you post the code here?, So we can better assist you to find the problem.

Waiting for reply.
Regards



hi! sorry for the very late reply.. anyway here's my code that I use to save new data..

CODE

Data1.Recordset.AddNew
Data1.Recordset.Fields("SUBJECT") = Text2.Text
Data1.Recordset.Fields("TOPIC") = Combo4
Data1.Recordset.Fields("UPDATE ON") = Text5.Text
Data1.Recordset.Fields("REF NO") = Text7.Text
Data1.Recordset.Fields("FOLDER") = Combo5.Text
Data1.Recordset.Fields("ISSUE DATE") = Text6.Text
Data1.Recordset.Fields("SIGNATORY") = Combo6.Text
Data1.Recordset.Fields("HYPERLINK") = Text9.Text
Data1.Recordset.Update
Label9.Refresh

MsgBox "Data has been saved", vbInformation + vbOKOnly, "Success"
Data1.Recordset.MoveLast



and here's the code that I use to open a pdf file using Label object

CODE

If Label9.Caption <> "" And Label9.Caption <> "-" Then
Label9.Refresh
hype = Label9.Caption
retval = ShellExecute(MEMOENTRY.hwnd, "Open", hype, 0&, 0&, 1)
Else
MsgBox "Invalid directory", vbCritical + vbOKOnly, "ERROR"
End If
Exit Sub


well, both are working great.. it's just that I will have to exit that particular screen before the newly added data especially the hyperlink will take effect.. usually, the hyperlink is in blue forecolor but if it is not active it is in black forecolor.. so everytime i save a new data, all hyperlinks are not active.. the thing is, i also have a delete button.. after deleting a certain record, it refreshes the hyperlinks without exiting the form.. im wondering how will i refresh the whole form without exiting the data.. help pls??
User is offlineProfile CardPM
+Quote Post

tica0419
RE: Refresh Form Without Exiting Or Unloading
20 Nov, 2007 - 09:21 PM
Post #4

New D.I.C Head
*

Joined: 8 Oct, 2007
Posts: 28


My Contributions
i just realized after thorough testing that everytime i add new data using the code above, it alters the 1st record of my database.. is there any way i can avoid that?
User is offlineProfile CardPM
+Quote Post

tica0419
RE: Refresh Form Without Exiting Or Unloading
21 Nov, 2007 - 09:34 PM
Post #5

New D.I.C Head
*

Joined: 8 Oct, 2007
Posts: 28


My Contributions
is there anyone who can help me with this?
User is offlineProfile CardPM
+Quote Post

kwikone
RE: Refresh Form Without Exiting Or Unloading
24 Nov, 2007 - 12:28 PM
Post #6

New D.I.C Head
Group Icon

Joined: 25 Oct, 2007
Posts: 10


Dream Kudos: 25
My Contributions
QUOTE(tica0419 @ 20 Nov, 2007 - 02:54 AM) *

hi! sorry for the very late reply.. anyway here's my code that I use to save new data..

<snip>
after deleting a certain record, it refreshes the hyperlinks without exiting the form.. im wondering how will i refresh the whole form without exiting the data.. help pls??

You don't have the code relevant to Label9. When adding a new record you need to have label 9 re-read all records and be attached to the same Data1.Recordset and do a refresh of the recordset not the label since the Label9.Refresh will not refresh the recordset as you seem believe. Try doing a Data1.Recordset.MoveFirst then Data1.Recordset.Movelast which will get it positioned onto the last record. The reason delete works is that when you delete a record at the end the recordset pointer gets set to the last record which is not deleted. And, depending upon your recordset type (static, dynamic) you may need to re-execute the recordset query.
User is offlineProfile CardPM
+Quote Post

tica0419
RE: Refresh Form Without Exiting Or Unloading
25 Nov, 2007 - 07:45 PM
Post #7

New D.I.C Head
*

Joined: 8 Oct, 2007
Posts: 28


My Contributions
QUOTE(kwikone @ 24 Nov, 2007 - 01:28 PM) *

QUOTE(tica0419 @ 20 Nov, 2007 - 02:54 AM) *

hi! sorry for the very late reply.. anyway here's my code that I use to save new data..

<snip>
after deleting a certain record, it refreshes the hyperlinks without exiting the form.. im wondering how will i refresh the whole form without exiting the data.. help pls??

You don't have the code relevant to Label9. When adding a new record you need to have label 9 re-read all records and be attached to the same Data1.Recordset and do a refresh of the recordset not the label since the Label9.Refresh will not refresh the recordset as you seem believe. Try doing a Data1.Recordset.MoveFirst then Data1.Recordset.Movelast which will get it positioned onto the last record. The reason delete works is that when you delete a record at the end the recordset pointer gets set to the last record which is not deleted. And, depending upon your recordset type (static, dynamic) you may need to re-execute the recordset query.


thanks for the time! smile.gif

anyway, i tried using this code based on what i have understood from your reply.. but unfortunately, it didn't work..

CODE

Private Sub cmdSave_Click()

prompt$ = "Save record?"
reply = msgbox (prompt$, vbokcancel + vbQuestion, "Record")

if reply = vbOK then
data1.recordset.movefirst
data1.recordset.addnew
data1.recordset.fields("sample") = text1.text
data1.recordset.update
data1.recordset.movelast

data1.databasename = (app. path + "/test.mdb")
data1.recordsource = "sampletable"

end if

end sub


This post has been edited by tica0419: 25 Nov, 2007 - 07:47 PM
User is offlineProfile CardPM
+Quote Post

tica0419
RE: Refresh Form Without Exiting Or Unloading
26 Nov, 2007 - 12:14 AM
Post #8

New D.I.C Head
*

Joined: 8 Oct, 2007
Posts: 28


My Contributions
hello again! i was able to resolve my issues with regards to refreshing the form.. the only problem left is adding/saving new records without altering/overwriting the first record or any existing record.. this is the code that im using as of the moment:

CODE


private sub cmdAddNew_Click()

data1.recordset.addnew
data1.recordset.fields ("sample") = text1.text
data1.recordset.update

end sub



can i get any help?????

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 10:16PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month