God this is annoying me, im sorry if this has been asked before but ive looked though the forum and the net but my searches havent come up woth anything.... mainly due to that i dont really know what to search for.
So here we go, i have a table in access called hopper that hold some info about a feed hopper ( max volume , feed_ID etc) i also have a table called feed which holds "feed_ID , Catagory" now i want to be able to add a new hopper to the hopper table, i have done that and it works fine but the part im stuck on is i want to check if the Feed_ID entered when creating the hopper is contained in the Feed table. ive been trying to use if and if not statements but im getting all mixed up :D
i hope someone can help :D and i think its kinda simple to do, but as i said i dont know what to search for :(
7 2256 QVeen72 1,445
Recognized Expert Top Contributor
Hi,
Open a Recordset to check ID is present or not :
use this SQL
sSQl = "Select * from MyTable Where ID =" & variablename
if u get RS.eof then (Not Present)
Regards
Veena
ty for your speedy responce, i had a go at the but being pritty much a noob @ vb :D
this i what i came up with:
form load
Set db3 = OpenDatabase(App.Path + "/cjmillers.mdb")
Set rs3 = db3.OpenRecordset("Feed")
'----------------------
Private Sub Command28_Click()
If txthopper(0).Text = "" Then
MsgBox "Please enter a Hopper ID", vbInformation, "MMS"
txthopper(0).SetFocus
Else
If txthopper(1).Text = "" Then
MsgBox "Please enter a Hopper Number", vbInformation, "MMS"
txthopper(1).SetFocus
Else
If txthopper(2).Text = "" Then
MsgBox "Please enter a Feed ID", vbInformation, "MMS"
txthopper(2).SetFocus
Else
If txthopper(3).Text = "" Then
MsgBox "Please enter a Catagory", vbInformation, "MMS"
txthopper(3).SetFocus
Else
If txthopper(4).Text = "" Then
MsgBox "Please enter a Maximum Feed", vbInformation, "MMS"
txthopper(4).SetFocus
Else
If txthopper(5).Text = "" Then
MsgBox "please enter The Feed Left", vbInformation, "MMS"
txthopper(5).SetFocus
Else
rs2.AddNew
txthopper(0).Text = rs2.Fields(0)
txthopper(1).Text = rs2.Fields(1)
txthopper(2).Text = rs2.Fields(2)
txthopper(3).Text = rs2.Fields(3)
txthopper(4).Text = rs2.Fields(4)
txthopper(5).Text = rs2.Fields(5)
rs2.Update
'-----------------------
Dim sSQL As String
sSQL = "Select * from Feed =" & Feed_ID
rs3.RecordSource = sSQL
rs3.Refresh
rs3.Recordset.MoveFirst
Do Until rs3.Recordset.EOF
rs3.MoveNext
Loop
End If
End If
End If
End If
End If
End If
End Sub
im now getting an error "94"
from txthopper(0).Text = rs2.Fields(0)
im not sure if the code for
Dim sSQL As String
sSQL = "Select * from Feed =" & Feed_ID
rs3.RecordSource = sSQL
rs3.Refresh
rs3.Recordset.MoveFirst
Do Until rs3.Recordset.EOF
rs3.MoveNext
is correct, plz comment :D
thanks once again.
QVeen72 1,445
Recognized Expert Top Contributor
Hi,
it shud be:
replace Table_name with ur table name
and Var_Feed_ID with ur variable name
sSQL = "Select * from Table_name Where Feed_ID =" & Var_Feed_ID
set rs3 = db3.Openrecordset(sSQL,dbOpenDynaset)
If rs3.RecordCount =0 Then
'ADD new Code here
Else
'Msg Box for duplicate entry....
End If
Regards
Veena
ok this is what i got - Private Sub Form_Load()
-
-
Set db = OpenDatabase(App.Path + "/cjmillers.mdb")
-
Set rs = db.OpenRecordset("Orders")
-
-
Set db1 = OpenDatabase(App.Path + "/cjmillers.mdb")
-
Set rs1 = db1.OpenRecordset("Orders")
-
-
Set db2 = OpenDatabase(App.Path + "/cjmillers.mdb")
-
Set rs2 = db2.OpenRecordset("Hopper")
-
-
Set db3 = OpenDatabase(App.Path + "/cjmillers.mdb")
-
Set rs3 = db3.OpenRecordset("Feed")
- Private Sub Command28_Click()
-
-
SQL = "Select * from Feed Where Feed_ID =" & txthopper(2).Text
-
-
-
Set rs3 = db3.OpenRecordset(sSQL, dbOpenDynaset)
-
If rs3.RecordCount = 0 Then
-
rs2.AddNew
-
txthopper(0).Text = rs2.Fields(0)
-
txthopper(1).Text = rs2.Fields(1)
-
txthopper(2).Text = rs2.Fields(2)
-
txthopper(3).Text = rs2.Fields(3)
-
txthopper(4).Text = rs2.Fields(4)
-
txthopper(5).Text = rs2.Fields(5)
-
rs2.Update
-
-
Else
-
MsgBox ("Feed ID entered does not exsisist")
-
End If
i get a error on line
Set rs3 = db3.OpenRecordset(sSQL, dbOpenDynaset)
i think its just that im tired :D all this text is just a blur tbh :D
QVeen72 1,445
Recognized Expert Top Contributor
Hi,
sSQL = "Select * from Feed Where Feed_ID =" & txthopper(2).Text
Check field name :
Feed_ID
txthopper(2) -- value of this text box..
Regards
Veena
nope same prob
all i get is - run-time error 424
-
Object required
then under the yellow error text:
dbOpenDynaset =2
sSQL = "Select * from Feed Where Feed_ID =10008"
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Phil Powell |
last post by:
The table already has a fulltext index and from there I can use the
MySQL fulltext search query to get results as well as the relevancy
score.
The problem I have is that MySQL has a default...
|
by: Dan |
last post by:
Hi, just ran into my first instance of a backend Access97 database not
compacting. I'm getting the "MSACCESS.EXE has generated errors.." message on
compact.
I've narrowed it down to the largest...
|
by: AW |
last post by:
Hi all,
I have a form (named Offices) with a subform (named Occupants) that connect
with the Master/Child Field "office number". I have a combo box that allows
a user to pull up a particular...
|
by: Christopher Koh |
last post by:
I will make a form which will search the database (just like google
interface) that will look/match for the exact name in the records of a
given fieldname. Any suggestions on how to make the code?
|
by: Steph |
last post by:
Hi.
I'm very new to MS Access and have been presented with an Access database
of contacts by my employer.
I am trying to redesign the main form of the database so that a button
entitled...
| |
by: Eric |
last post by:
Hi: I have two files. I search pattern ":" from emails text file and
save email contents into a database. Another search pattern " field is blank. Please try again.",
vbExclamation + vbOKOnly...
|
by: rszebras |
last post by:
I inherited a database (as a novice at Access) and need to modify it to
make it more efficient, i.e., the assignment form needs to autopopulate
with the client's name, address, phone number, etc.,...
|
by: jonathan184 |
last post by:
Hi I tried getting this to work through dreamweaver but it did not.
So i found a n example on the internet , i followed everything exactly the search script does not work. Could somebody help me...
|
by: jfarthing |
last post by:
Hi everyone!
I am using the script below to search a db. If the is more than one match in the db, all goes well. But if there is only one match in the db, nothing gets displayed.
Any...
|
by: iahamed |
last post by:
Hi Everyone,
I got two parts of my advance search to work, I am running out of Logic to
connect the third. My mind is in swing! Pleaseeeeeeeee Help me.
I have 3 Fiels to search, the First two...
|
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: 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...
|
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,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 ...
| |