473,378 Members | 1,523 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Refreshing form

Fa
Hi,
I'm using this code to pass "codice cliente" values from a form1 to
form2.

Private Sub Form_Open(Cancel As Integer)
Me.RecordsetClone.FindFirst "[Codice cliente]=" & Forms!
[frmAnagraficaClienti_Principale]![Codice cliente]
If Me.RecordsetClone.NoMatch Then
Me.RecordsetClone.AddNew
Me.RecordsetClone![Codice cliente] = Forms!
[frmAnagraficaClienti_Principale]![Codice cliente]
Me.RecordsetClone.Update
Me.Requery
Else
Me.Bookmark = Me.RecordsetClone.Bookmark
End If
End Sub

At the first time I click button on form1 to open form2, form2 dosn't
catch the right "codice cliente" of form1 and display its first
record.
At the second time form2 goes to the correct record with the right
"codice cliente".

I need to add some records in a new popup form when I click a button
in form1.

Tks for your help, I'm a newbie.
Fa

Mar 28 '07 #1
2 2621
There is no need to Requery, since the record is in the clone set.

However, several things could go wrong in that process:
a) The other form may not be open.
b) The other form may have a partially entered record that cannot be saved.
c) This form may have a dirty record too.
d) The recordset may not be at the newly added record, unless you explicitly
set it using the LastModified bookmark.
e) I'm not sure about the wisdom of doing all this in Form_Open.

Try something like this:

Dim frm As Form
Dim rs As DAO.Recordset

If CurrentProject.AllForms![frmAnagraficaClienti_Principale].IsLoaded
Then
If Me.Dirty Then
Me.Dirty = False
End If
Set frm = Forms![frmAnagraficaClienti_Principale]
If frm.Dirty Then
frm.Dirty = False
End If

If IsNull(frm![Codice cliente]) Then
MsgBox "Nobody home"
Else
Set rs = Me.RecordsetClone
rs.FindFirst "[Codice cliente] = " & frm![Codice cliente]
If rs.NoMatch Then
rs.AddNew
rs![Codice cliente] = frm![Codice cliente]
rs.Update
Me.Bookmark = rs.LastModified
Else
Me.Bookmark = rs.Bookmark
End If
End If
End If

(Needs error handling in case the save fails.)

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Fa" <fa*******@gmail.comwrote in message
news:11**********************@y80g2000hsf.googlegr oups.com...
Hi,
I'm using this code to pass "codice cliente" values from a form1 to
form2.

Private Sub Form_Open(Cancel As Integer)
Me.RecordsetClone.FindFirst "[Codice cliente]=" & Forms!
[frmAnagraficaClienti_Principale]![Codice cliente]
If Me.RecordsetClone.NoMatch Then
Me.RecordsetClone.AddNew
Me.RecordsetClone![Codice cliente] = Forms!
[frmAnagraficaClienti_Principale]![Codice cliente]
Me.RecordsetClone.Update
Me.Requery
Else
Me.Bookmark = Me.RecordsetClone.Bookmark
End If
End Sub

At the first time I click button on form1 to open form2, form2 dosn't
catch the right "codice cliente" of form1 and display its first
record.
At the second time form2 goes to the correct record with the right
"codice cliente".

I need to add some records in a new popup form when I click a button
in form1.

Tks for your help, I'm a newbie.
Fa
Mar 28 '07 #2
Try something like this:
>
Dim frm As Form
Dim rs As DAO.Recordset

If CurrentProject.AllForms![frmAnagraficaClienti_Principale].IsLoaded
Then
If Me.Dirty Then
Me.Dirty = False
End If
Set frm = Forms![frmAnagraficaClienti_Principale]
If frm.Dirty Then
frm.Dirty = False
End If

If IsNull(frm![Codice cliente]) Then
MsgBox "Nobody home"
Else
Set rs = Me.RecordsetClone
rs.FindFirst "[Codice cliente] = " & frm![Codice cliente]
If rs.NoMatch Then
rs.AddNew
rs![Codice cliente] = frm![Codice cliente]
rs.Update
Me.Bookmark = rs.LastModified
Else
Me.Bookmark = rs.Bookmark
End If
End If
End If

(Needs error handling in case the save fails.)
Tks you very much, this code is perfect and run very well...I spend several
days to solve my problem with no results.
Now I'm searching some info about dirty command and the right use of
recordsetclone.
Ciao!, Fa
Mar 28 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Philo Del Middleston | last post by:
I've been searching, but apparently not phrasing my search right, so I'm going to float a question out here in the meantime... I'm wondering how to go about refreshing the content of a control...
1
by: LRD | last post by:
Form not refreshing after autopostback unless keyboard or mouse move Hi, We created several new ASP.NET C# forms for our intranet. In each form we use panels for different sections of the...
0
by: Mark Payne | last post by:
Gudday, I have an Access 2000 database which I am using as a phone directory of residents in the hostel where I work. The front end for this directory is a form with a text box (the search name...
1
by: Robert Clark | last post by:
This a pocket pc/smartphone questions mainly, but i thought i'd ask the question in the C# newsgroup. I have a form which i use to display information from a web service. From this form i open...
3
by: Steve Hoyer | last post by:
Good day. I wrote an application to convert data from one database to another. It runs through about 100,000 records for this conversion. That bit works fine. I have on the form a progress...
6
by: Chris Moore | last post by:
I have a .NET form where I am updating a progress bar & counter. As long as the form never loses focus, everything on the form refreshs fine. But If I open another window (like Windows Explorer)...
2
by: dmartin_1 | last post by:
I'm building an application with Visual Basic 2005. The application is multi threaded. It has a record counter on the form that counts up to completion. It works fine throughout the process as...
0
by: sean.hpr | last post by:
Hi all- I am a vb2005 newb so apologies in advance. Essentially I am having some problems with data refreshing on some of my forms. Background: I have created a project containing a few...
13
by: honey99 | last post by:
Hi! I have to fix a problem in JSP.Actually,i have a JSP page say Ex1.jsp.In this Ex1.jsp i have an anchor tag which links into another JSP page i.e when i click on the link another pop-up window...
6
by: shankari07 | last post by:
hi guys, I have a form in html which has the city drop down. when clicking the drop down a javascript is called and a file(test.txt) is created and the city is written into the file. Through php...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.