473,703 Members | 2,912 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Looking for same data in two tables

Hi

I got the following case:

I got to tables named "Table1" and "Table2"
Both tables got the same fields. When data in table1 are used they are
moved to table2. The fields I am interested in is "Nummer" and
"VareNr_"

I got a form with 2 textboxes called "PNr" and "VareNr".
When the user type a text in "PNr", this text should be verified to
match a record first in Table1.Nummer. If i doesn't fid it there, it
goes to Table2 and if it aren't there too it display a messagebox.

Now if i find the record, the TableX.VareNr_ value should be put into
the Form.VareNr textbox !

If it only was one table I should look in, I find it very simple, but
with to tables itget complicated for me.

I have tryed this in the VBA editor, but can't get it right. I got the
error message "Compile error User-defined type not defined"

Private Sub PNr_AfterUpdate ()

Dim DB As Database
Dim strQueryTable1 As String
Dim strQueryTable2 As String
Dim rst As Recordset

Set DB = CurrentDb()
strTableX = "Table1.VareNr_ "
strQueryTable1 = "SELECT Table1.VareNr_ FROM Table1 WHERE
Table1.Nummer = 'ME!PNr'"
strQueryTable1 = "SELECT Table2.VareNr_ FROM Table2 WHERE
Table2.Nummer = 'ME!PNr'"
MsgBox strQuery

If DB.OpenRecordse t(strQueryTable 1, [..]) Then
Set Me!VareNr = DB.OpenRecordse t(strQueryTable 1, [..])
ElseIf DB.OpenRecordse t(strQueryTable 2, [..]) Then
Set Me!VareNr = DB.OpenRecordse t(strQueryTable 2, [..])
Else
MsgBox "No such record. Try a new one"

End Sub

Please help me :-)
Nov 13 '05 #1
1 1235
The data structure you describe is NOT normalized anything like a relational
database, and few people are going to encourage you to continue with it and
provide workarounds for a deeply flawed structure. Search for and look at
some examples of good data designs.
-Ed

"Briton" <br****@get2net .dk> wrote in message
news:6a******** *************** ***@posting.goo gle.com...
Hi

I got the following case:

I got to tables named "Table1" and "Table2"
Both tables got the same fields. When data in table1 are used they are
moved to table2. The fields I am interested in is "Nummer" and
"VareNr_"

I got a form with 2 textboxes called "PNr" and "VareNr".
When the user type a text in "PNr", this text should be verified to
match a record first in Table1.Nummer. If i doesn't fid it there, it
goes to Table2 and if it aren't there too it display a messagebox.

Now if i find the record, the TableX.VareNr_ value should be put into
the Form.VareNr textbox !

If it only was one table I should look in, I find it very simple, but
with to tables itget complicated for me.

I have tryed this in the VBA editor, but can't get it right. I got the
error message "Compile error User-defined type not defined"

Private Sub PNr_AfterUpdate ()

Dim DB As Database
Dim strQueryTable1 As String
Dim strQueryTable2 As String
Dim rst As Recordset

Set DB = CurrentDb()
strTableX = "Table1.VareNr_ "
strQueryTable1 = "SELECT Table1.VareNr_ FROM Table1 WHERE
Table1.Nummer = 'ME!PNr'"
strQueryTable1 = "SELECT Table2.VareNr_ FROM Table2 WHERE
Table2.Nummer = 'ME!PNr'"
MsgBox strQuery

If DB.OpenRecordse t(strQueryTable 1, [..]) Then
Set Me!VareNr = DB.OpenRecordse t(strQueryTable 1, [..])
ElseIf DB.OpenRecordse t(strQueryTable 2, [..]) Then
Set Me!VareNr = DB.OpenRecordse t(strQueryTable 2, [..])
Else
MsgBox "No such record. Try a new one"

End Sub

Please help me :-)

Nov 13 '05 #2

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

Similar topics

22
2280
by: Martin MOKREJ© | last post by:
Hi, I'm looking for some easy way to do something like include in c or PHP. Imagine I would like to have: cat somefile.py a = 222 b = 111 c = 9
1
3438
by: Simeon Nevel | last post by:
As a personal exercise, I'm trying to create a call tracking DB for my own use at work. Here's an abbreviated version of the database layout: Company: CompanyID - Primary Key (Text Length 4) CompanyName OtherData
0
1481
by: Megan | last post by:
Hi Everybody- I know that this is a really, really long post, but I wanted to try to give you as much background as possible. So here's a quick overview of the issues I'm asking for help with: 1.) I'm trying to create a many to many relationship, and I get the following Error when I try to enforce referential integrity.
4
2033
by: Maria | last post by:
One of my duties is to record student grades each report period(6). The tables in the database basically look like: TblStudent StudentID Name etc TblStudentGrade StudentGradeID GradePeriod
2
1282
by: David++ | last post by:
Dear List, Is it possible to have a schema with tables of the same name? I need to build an XML document based on the following schema - <?xml version="1.0" encoding="utf-8"?> <xs:schema id="Recordlist" targetNamespace="http://tempuri.org/Recordlist.xsd" elementFormDefault="qualified" xmlns="http://tempuri.org/Recordlist.xsd" xmlns:mstns="http://tempuri.org/Recordlist.xsd"
2
3607
by: SmartbizAustralia | last post by:
Hi, This seems to be a neglected bit of info as everyone gets carried away with data binding examples instead. Can simply use the datareader as below: Private Sub PopulateControls1() Dim sSql As String Dim cn As SqlConnection
0
1995
by: AMDRIT | last post by:
I am looking for better concrete examples, as I am a bit dense, on design patterns that facilitate my goals. I have been out to the code project, planet source code, and microsoft's patterns and practices site and it just isn't sinking in all that clearly to me. Currently we have code in production and it all works well, however it is not the way we want it. We know that we can implement a better design plan to improve performance,...
2
2086
kcdoell
by: kcdoell | last post by:
Hello: I have four tables: tblDivision tblWorking_Region tblCredit_Region tblForecast (This is the main data entry table for all forecasting records) tblDivision has the following fields:
0
8662
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9244
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9004
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7853
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4421
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4679
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3114
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2439
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2058
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.